
| Line: 1 to 1 | ||||||||
|---|---|---|---|---|---|---|---|---|
| Added: | ||||||||
| > > |
Eighth Programming Lab, ITSC 121, Spring 2020OverviewWrite the following programs. The first one deals counting occurrences. The second deals with stats on scores. The third one deals with timing searches. The last is extra credit and deals with the command line.Program 1: Counting occurrences (problem 7.3)Write a program that reads in the integers between 1 and 100 and counts the occurrences of each. Assume the input ends with a 0. Here is a sample run of the program.Enter the integers between 1 and 100: 2 5 6 5 4 3 23 43 2 0 2 occurs 2 times 3 occurs 1 time 4 occurs 1 time 5 occurs 2 times 6 occurs 1 time 23 occurs 1 time 43 occurs 1 time Note if a number occurs more than one time, the plural word "times" is used in the output. A hint can be found ITSC121SP2020Lab8Hint1 | here. If you use the hint (i.e. read it), you must document that fact in your write-up. Program 2: Stats (problem 7.4)Write a program that reads an unspecified number of scores and determines how many scores are above or equal to the average, and how many scores are below the average. Enter a negative number to signify the end of the input. Assume the maximum number of scores is 100.Program 3: Timing (problem 7.16 adapted)Write a program that randomly generates an array of 100,000 integers and a key. Estimate the execution time of each of the following:
long startTime, endTime, executionTime;
... // includes loading the array;
startTime = System.nanoTime();
found = linearSearch(dataValues,key);
endTime = System.nanoTime();
executionTime = endTime - startTime;
System.out.print(exeuctionTime);
Program 4: command line (extra credit) (problem 7.21)Write a program that passes an unspecified number of integers from the command line and displays their total.Reminders
Submissions
| |||||||