1
Student Name: __________________
Class and Section __________________
Total Points (20 pts) __________________
Due: October 5, 2016 before the class
Project: Occurrence of Max Value
CSCI 1301 Introduction to Programming Principles
Armstrong Atlantic State University
Problem Description:
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. (Hint: Maintain
two variables, max and count. max stores the current max number, and count stores its
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, increment count by 1.)
Here are sample runs of the program:
Sample 1:
Analysis:
(Describe the problem including input and output in your own words.)
Design:
(Describe the major steps for solving the problem.)
2
Testing: (Describe how you test this program)
Submit the following items:
1. Print this Word file and Submit to me before the class on the due day
3
Code Solution:
public class Test {
public static void main(String[] args) {
java.util.Scanner input = new java.util.Scanner(System.in);