-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChecknumber.java
More file actions
34 lines (26 loc) · 849 Bytes
/
Checknumber.java
File metadata and controls
34 lines (26 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
*/
package com.mycompany.checknumber;
/**
*
* @author ERIC
*/
import java.util.Scanner;
public class Checknumber {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// Prompt user for input
System.out.print("Enter a number: ");
double number = scanner.nextDouble();
// Check whether the number is positive, negative, or zero
if (number > 0) {
System.out.println(number + " is a positive number.");
} else if (number < 0) {
System.out.println(number + " is a negative number.");
} else {
System.out.println("The number is zero.");
}
scanner.close();
}
}