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: 77% (9 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...
-
Preparing a columnar work sheet for a statement of cash flows from changes in balance sheet accounts. The balance sheets of GreeTi Mountain Coffee Roasters allow the following computation of changes...
-
()ki (ompany pays $204,000 lor e(|uipmenl expected lo Iasi lour years and have a $20,000 salvage value. Prepare journiil enirics lo record Ibe rollowing costs relaled lo (be e(|uipnienl. 1. I fill...
-
Think about how you would organize a data warehouse for Marathon Vitamin Shops. What other databases would you like to merge into the data warehouse? What sort of patterns should Bill Berry be...
-
Project L requires an initial outlay att 0 of $35,000, its expected cash inflows are $10,000 per year for 9 years, and its WACC is 9%. What is the project's discounted payback? Do not round...
-
The Miller Company uses skilled and unskilled labor to do a particular construction project. The cost of doing the project depends on the number of hours of skilled labor and the number of hours of...
-
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...
-
Using the data in BE2-5, journalize the transactions. (You may omit explanations.)
-
Benchmark has an optimal target capital structure consisting of a debt-to-assets ratio of 60 percent. Benchmark can raise up to $5 million in new debt at a before-tax cost of 8 percent. If more debt...
-
Turn this information into an excel sheets with the excel formulas being shown P13.2 (LO 1, 2) (Issuance and Redemption of Bonds) Venezuela Co. is building a new hockey arena at a cost of $2,500,000....
-
2. An engineering firm hires you to certify a heated concrete floor design, as shown in Fig 2. Hot water flows through pipes that are embedded in the concrete slab. The water temperature inside the...
-
Calculate gross and net sales for your company. You are working in fashion design as an office assistant. The designer wants to know how the sale of the product has performed financially in the first...
-
71 Question 17 (4 points) You have a good business model in Canada. In Kitchener, you prepare prepackaged frozen healthy meals and sell these to households via your own webpage shop. Most of your...
-
Trent, a minor, bought a copyrighted CD from Shawn. After making a copy of the disc, Trent found a defect in the CD. He tried to return it to Shawn for a full refund. Shawn suspected the illegal...
-
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...
-
Jupitor company sells a single product $50 per unit. Contribution Margin Ratio is 40%. Monthly Fixed Costs are $228,899. Profit is $150,000. How many units to target profit of $328,433?
-
IV. Cross rates A. Define a cross rate and discuss why it is useful. (You will practice the calculation multiple times in homework). B. Complete this problem a CI 1.4 Munich to Moscow. For your...
-
51 Find the Effective Annual Rate for 21.6 % compounded weekly
Study smarter with the SolutionInn App