-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinfintenumb.java
More file actions
31 lines (29 loc) · 914 Bytes
/
infintenumb.java
File metadata and controls
31 lines (29 loc) · 914 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
import java.util.Scanner;
public class infintenumb {
public static void main(String[] args){
Scanner s=new Scanner(System.in);
int n,
countPositive=0,
countnegative=0,
countzeros=0;
char choice;
do{
System.out.println("Enter numb :");
n=s.nextInt();
if(n>0){
countPositive++;
}
else if(n<0){
countnegative++;
}
else {
countzeros++;
}
System.out.println("Do you want to continue yes/no? ");
choice=s.next() .charAt(0);
}while(choice=='y' || choice=='y');
System.out.println("Positive count =" + countPositive);
System.out.println("Negative count =" +countnegative);
System.out.println("Zero count =" +countzeros);
}
}