Question: ( 4 0 pts ) This problem deals with reading input from the keyboard and files and applying simple arithmetic calculations. Create class ProductCumulator with

(40 pts) This problem deals with reading input from the keyboard and files and applying simple arithmetic calculations. Create class ProductCumulator with the following methods and steps:
i. void ProductFromKeyboard():
Step 1: Outputs the following: "Please input a series of positive ints, using the
Step 2: Takes a sequence of input positive integer values from the keyboard and multiplies them together until a zero or negative integer is encountered.
Step 3: Prints the product of all positive values provided in Step 2(if none are provided, 1 is output.)
Ex: If the following is input from the keyboard:
4
2
7
-1
then the output should be along the lines of "The product of input values is 56.."
ii. void ProductFromFile(String filename):
Identical to ProductFromKeyboard, but must take the sequence of integers from the file defined according to filename. You can assume that i. only integer values will be provided and ii. at least one non-positive value will be provided in the file. You can and should stop immediately as soon as the non-positive value is seen. Ex: if the included file "sample_intsequence.txt" is given as input, the output should be along the lines of "The product of input values is 120."
Note: You will want to refer to the last part of chapter 2's slides and code for insight into reading input with Java. You will also require if statements.
 (40 pts) This problem deals with reading input from the keyboard

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!