Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Program Read in integer numbers, white space separated (free form data - a white space is either space, tab or newline just use nextInt()

Java Program

Read in integer numbers, white space separated (free form data - a white space is either space, tab or newline just use nextInt() ), stop reading when you input 0, you will output the number of positive integers, negative integers, sum and floating-point average (type double - 2 digits after decimal point). You will first prompt the user with the string "Enter an integer, the input ends if it is 0: "

"(Count positive and negative numbers and compute the average of numbers) Write a program that reads an unspecified number of integers, determines how many positive and negative values have been read, and computes the total and average of the input values (not counting zeros). Your program ends with the input 0. Display the average as a floating-point number, using the standard "%,.2f" format specifier.

Here's how program needs to look like:

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Sample run 1: Enter an integer, the input ends if it is 0: 1 2 -1 9 0 The number of positives is 3 The number of negatives is 1 The total is 11 Average is 2.75 Sample Run 2: Enter an integer, the input ends if it is 0: 0 No numbers were entered except 0 Sample Run 3: using Input String "2 -2 4 6 6 0 3 4 5 " in Scanner Enter an integer, the input ends if it is 0: The number of positives is 4 The number of negatives is 1 The total is 16 Average is 3.20 

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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

Step: 3

blur-text-image

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

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

More Books

Students also viewed these Databases questions

Question

=+Do you want to work from home?

Answered: 1 week ago