Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

How to find the largest number and it's occurrences from user'

$
0
0
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);
}

}

}

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>