Write a program that reads integers, finds the largest of them, and counts its occurrences. Assume that the input ends with number 0. Suppose that you entered 3 5 2 5 5 5 0; the program finds that the largest is 5 and the occurrence count for 5 is 4.
My program makes no sense right now because I am lost. Can someone point me in a direction please.
import java.util.Scanner;
public class Occurances {
public static void main(String[] args) {
//Declare class variables
int count = 0;
int number = 0;
int max = 0;
//input user data
Scanner input = new Scanner(System.in);
System.out.println("Enter numbers: ");
//Display max and occurrence
for (max = 0; max <= new; max++) {
System.out.println("The largest number is: ", max);
System.out.println("The occurrence count of the largest number is ", count);
}
}
}
My program makes no sense right now because I am lost. Can someone point me in a direction please.
import java.util.Scanner;
public class Occurances {
public static void main(String[] args) {
//Declare class variables
int count = 0;
int number = 0;
int max = 0;
//input user data
Scanner input = new Scanner(System.in);
System.out.println("Enter numbers: ");
//Display max and occurrence
for (max = 0; max <= new; max++) {
System.out.println("The largest number is: ", max);
System.out.println("The occurrence count of the largest number is ", count);
}
}
}