Write a program that reads an unspecified number of integers, determines how many positive and negative values
Question:
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. Here is a sample run:
Transcribed Image Text:
Enter an integer, the input ends if it is 0: 1 2 -1 3 0 JEnter The number of positives is 3 The number of negatives is 1 The total is 5.0 The average is 1.25 Enter an integer, the input ends if it is 0: 0 -Enter No numbers are entered except 0
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 87% (8 reviews)
Program Plan Define a class named CountNumbers o Define the main method Define the Scanner class obj...View the full answer
Answered By
Muhammad Umair
I have done job as Embedded System Engineer for just four months but after it i have decided to open my own lab and to work on projects that i can launch my own product in market. I work on different softwares like Proteus, Mikroc to program Embedded Systems. My basic work is on Embedded Systems. I have skills in Autocad, Proteus, C++, C programming and i love to share these skills to other to enhance my knowledge too.
3.50+
1+ Reviews
10+ Question Solved
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Question Posted:
Students also viewed these Computer science questions
-
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...
-
Write a program that reads an unspecified number of integers and finds the one that has the most occurrences. The input ends when the input is 0. For example, if you entered 2 3 40 3 5 4 3 3 3 2 0,...
-
Write a program that reads an integer between 0 and 1000 and adds all the digits in the integer. For example, if an integer is 932, the sum of all its digits is 14. Use the % operator to extract...
-
Write a method leve1Order() that prints BST keys in level order: first print the root; then the nodes one level below the root, left to right; then the nodes two levels below the root (left to...
-
What is the largest n for which one can solve within one second a problem using an algorithm that requires f (n) bit operations, where each bit operation is carried out in 109 seconds, with these...
-
The boat is originally traveling at a speed of 8 m/s when it is subjected to the acceleration shown in the graph. Determine the boats maximum speed and the time t when it stops. - t(s) 1 24 9 + 1//3...
-
Is flowcharting useful in analyzing the resources required to implement a system?
-
Aquatic Biotechnology Inc. (ABI) is a medium-sized, public company operating an aquaculture business in eastern Canada. The company has been in operation since the mid-1990s, and during the latter...
-
The price of Ervin Corp. stock will either be $63 or $82 at the end of the year. Call options are available with one year until expiration. Continuously compounded T-bills currently yield 2.31 %....
-
What is the output of the following Python code? int_list = [0, 1, 2, 3, 4, 5] ch = 0 %3D element = 0 while element is int_list[ch]: print(element, end="") ch = ch + 1 element = int_list[ch+1] else:...
-
Maquoketa Services was formed on May 1, 2022. The following transactions took place during the first month. Transactions on May 1: 1. Jay Bradford invested $40,000 cash in the company, as its sole...
-
Listing 5.4, SubtractionQuizLoop.java, generates five random subtraction questions. Revise the program to generate ten random addition questions for two integers between 1 and 15. Display the correct...
-
Collect online mentions for three major media outlets. Choose from such media as The New York Times (www.nytimes.com), The Wall Street Journal (http://online.wsj.com/home-page), FOX News...
-
_____ are valued returns (such as incentive pay for performance) to the individual in exchange for doing something that the organization desires of the employee.
-
Outline the steps that must be undertaken when constructing a control flowchart. Be sure to indicate the critical decisions that must be made at each step.
-
_____ is something that the employee feels they have a right to receive from the company.
-
_____ provide a portion of company proceeds over a specific period of time (usually either quarterly or annually) to the employees of the firm through a bonus payment.
-
For each of the four types of control flowcharts described in the chapter, give a strength and a limitation.
-
What potential problems exist in agency relationships?
-
Juarez worked for Westarz Homes at construction sites for five years. Bever was a superintendent at construction sites, supervising subcontractors and moving trash from sites to landfills. He...
-
Rewrite the preceding servlet. Assume for each class, a table is used to store the student name, ssn, and score. The table name is the same as the class ID. For instance, if the class ID were...
-
Write a servlet that enables the user to change the password from an HTML form, as shown in Figure 37.30a. Suppose the user information is stored in a database table named Account with three columns:...
-
Write an HTML form that prompts the user to enter or select a JDBC driver, database URL, username, password, and table name, as shown in Figure 37.31a. Clicking the Submit button displays the table...
-
Pisa Pizza, a seller of frozen pizza, is considering introducing a healthier version of its pizza that will be low in cholesterol and contain no trans fats. The firm expects that sales of the new...
-
How much would $40,000 due in 30 years be worth today if the discount rate were 5.5%? Identify N, PV, FV, PMT, and I/R, and include the formula for calculating the answer.
-
Fish, Inc. converted to an S corporation on January 1, 20x5. At that time, Fish, Inc. had cash ($40,000), inventory (FMV $60,000, Basis $30,000), accounts receivable (FMV $40,000, Basis $40,000), and...
Study smarter with the SolutionInn App