Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

( 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.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Computer Aided Database Design

Authors: Antonio Albano, Valeria De Antonellis, A. Di Leva

1st Edition

0444877355, 978-0444877352

More Books

Students explore these related Databases questions