Question: Program Description Assignment #2 will be the construction of a program that reads in an unspecified number of integers from standard input, performs some calculations

Program Description

Assignment #2 will be the construction of a program that reads in an unspecified number of integers from standard input, performs some calculations on the inputted numbers, and outputs the results of those calculations to standard output. The numbers could be delimited by any kind of whitespace, i.e. tabs, spaces, and lines (Note that if you use the Scanner class, you do not have to worry about these delimiters. They will be taken care of).

The use of the following items, discussed in class, will probably be needed:

Documentation Primitive Data Types Basic I/O Expressions Conditional and Loop statements

Your program will continue to read in numbers until the number 0 is entered. At this point, the calculations will be outputted in the following format:

The minimum integer is 0 The count of odd integers in the sequence is 0

The largest even integer in the sequence is 0 The sum of positive integers is 0

This means that using all numbers your program reads (including the last number 0), you need to compute the minimum, count how many odd integers (cannot be divided by 2, num%2 != 0), compute the largest even integer (can be divided by 2, "num%2 == 0"), and compute the sum of positive integers.

Note that the above is an output for the first test case. For other test cases, you will have different numbers.

Do not prompt to query for the numbers. The number 0 is included in the sequence of integers and should be included in all of your calculations.

Try the following input cases to see if you get the correct output.

Input #1: 0

Output #1:

The minimum integer is 0

The count of odd integers in the sequence is 0

The largest even integer in the sequence is 0

The sum of positive integers is 0

Input #2: -1, 2, 0

Output #2:

The minimum integer is -1

The count of odd integers in the sequence is 1

The largest even integer in the sequence is 2

The sum of positive integers is 2

Input #3: -1, -2, -45, -90, 1.23, 679, 90, 0

Output #3:

The minimum integer is -90

The count of odd integers in the sequence is 5

The largest even integer in the sequence is 90

The sum of positive integers is 793

Input #4: 4, -3, 0, -1, 2

Output #4:

The minimum integer is -3

The count of odd integers in the sequence is 1

The largest even integer in the sequence is 4

The sum of positive integers is 4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!