一道Java的题目 求编程

问题描述:

一道Java的题目 求编程
Problem Description:
Write a program that reads integers,findsthe largest of them,and counts its occurrences.Assume that the input endswith number 0.Suppose that you entered 3 5 2 5 5 5 0; the program finds thatthe largest is 5 and the occurrence count for 5 is 4.(Hint:Maintain twovariables,max and count.max stores the current max number,and count storesits occurrences.Initially,assign the first number to max and 1 to count.Compare each subsequent number with max.If the number is greater than max,assign it to max and reset count to 1.If the number is equal to max,incrementcount by 1.)
Here are sample runs of the program:
Sample 1:
Enternumbers:3 5 2 5 5 5 0
Thelargest number is 5
Theoccurrence count of the largest number is 4
Sample 2:
Enternumbers:3 6 5 4 2 4 5 4 55 0
Thelargest number is 6
Theoccurrence count of the largest number is 1

首先你读懂题没有,我帮你翻译一下:问题描述: 编写一个程序,读取整数,找出其中最大的,并计算其出现次数.假设输入与数字0结束.假设你进入3 5 2 5 5 5 0;程序发现,最大的为5,出现次数为4. (提示:建立两个变量,...