Computer Science, asked by tejvirsinghu358, 1 year ago

Write a program to enter the numbers till the user wants and at the end it should display the count of positive, negative and zeros entered.

Answers

Answered by AbhiShekVR467
1
I don't understand what u say
Answered by crpiyushbansal
1

Answer:

public static void main(String[]args) {

   Scanner sc = new Scanner(System.in);

   int num,zero_counter=0,positive_counter=0, negetive_counter=0;

   char s;

   do {

       System.out.println("ENTER THE NUMBER OF YOUR CHOICE");

       num= sc.nextInt();

       if(num>0){

           positive_counter++;

       }

       else if(num<0){

           negetive_counter++;

       }

       else{

           zero_counter++;

       }

       System.out.println("DO YOU WANT TO CONTINUE Y/N");

       s=sc.next().charAt(0);

   }while (s=='y' || s=='Y');

   System.out.println(positive_counter);

   System.out.println(negetive_counter);

   System.out.println(zero_counter);

   }

}

Explanation:

Similar questions