HW4.41

时间:2023-03-09 22:28:30
HW4.41

HW4.41

 import java.util.Scanner;

 public class Solution
 {
     public static void main(String[] args)
     {
         Scanner input = new Scanner(System.in);

         System.out.print("Enter numbers: ");

         int max = 0;
         int count = 0;
         int number;

         while(true)
         {
             number = input.nextInt();
             if(number == 0)
                 break;
             if(number > max)
             {
                 max = number;
                 count = 0;
             }
             if(number == max)
                 count++;
         }

         input.close();

         System.out.println("The largest number is " + max);
         System.out.println("The occurence count of the largest number is " + count);
     }
 }