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: 85% (7 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...
-
Why does the entropy of a gas increase when it expands into a vacuum?
-
Redesign the VOCs adsorber of Example 9.15 for a breakthrough time of \(4.0 \mathrm{~h}\). The pressure drop through the bed [calculated using the Ergun equation (2-95)] should not exceed \(1.0...
-
On June 1, 2014, Ellie Hopkins established an interior decorating business, First-Class Designs. During the month, Ellie completed the following transactions related to the business: June 1. Ellie...
-
A professor designing a class demonstration connects a parallel-plate capacitor to a battery, so that the potential difference between the plates is 255 V. Assume a plate separation of d = 1.72 cm...
-
Match the following DEs to the scenario which best describes them. dA -0.25A - 25 Choose... dt dA 25 + 0.25A Choose... dt dA 0.25A Choose... dt dA dt 25 Choose... dA = 0.25A 25 dt Choose...
-
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...
-
Rim Corporation has 5,000 shares of its $100 par value, 7 percent cumulative preferred stock outstanding, and 25,000 shares of its $1 par value common stock outstanding. In Rims first four years of...
-
Who is responsible for the misconduct when looking at the scandal through the CSR lens? It is VW as a whole? Is it senior management who set very ambitious targets for the company? Is it the...
-
which one of the following choices is the correct way to declare a class"Bird" which specifies an abstract "flies" method that returns a boolean? 1. public abstract class Bird { public abstract...
-
Question 5 There was recently a change in the leadership team at Chamalo Inc, with a heavier focus on reinvesting for future growth. If the company has reinvested 50% of its after-tax EBIT last year...
-
If the gravitational force (Fg) increases by 9 times when both m and m are reduced by half, the new radius (12) must be what multiple of the original radius?
-
Identify a drawback of the Servant Follower Leadership theory?
-
Explain how materiality differs for misstatements of the financial report and inability to obtain sufficient appropriate audit evidence.
-
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...
-
Assume that Northern Petroleum Inc. issued the following bond on January 1: Face amount: $100,000 Contract interest rate: 12% Effective interest rate: 12% Interest is paid semiannually on January 1...
-
You are choosing between two projects. The cash flows for the projects are given in the following table ($ million): Project A B Year 0 -$51 - $101 a. What are the IRRS of the two projects? Year 1...
-
(5) For each of the following sets with a binary operation, determine if it a group or not and explain why. If it is not a group, you should provide at least one of the properties which is not...
Study smarter with the SolutionInn App