Page 218 - CA_Blue( J )_Class9
P. 218

10              {
                    11                  System.out.print("Enter the number ");

                    12                  num = sc.nextInt();
                    13                  if(num > 0)

                    14                  {
                    15                      p++;
                    16                  }

                    17                  else if(num < 0)

                    18                  {
                    19                      n++;
                    20                  }

                    21                  else
                    22                  {

                    23                      z++;
                    24                  }

                    25                  System.out.print("Do you want to continue y/n? ");
                    26                  choice = sc.next().charAt(0);

                    27              }while(choice=='y' || choice == 'Y');
                    28              System.out.println("Positive numbers: " + p);

                    29              System.out.println("Negative numbers: " + n);
                    30              System.out.println("Zero numbers: " + z);

                    31          }
                    32      }

                  You will get the following output:




























                   216    Touchpad Computer Applications-IX
   213   214   215   216   217   218   219   220   221   222   223