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...
-
Which of the following kingdoms or domains is a hodgepodge of different evolutionary lineages? A. Bacteria; B. Protista; C. Archaea; D. Plantae; E. Animalia
-
Why is the Industrial Revolution significant for managers?
-
In 2011, Troy wins the Connecticut Lotto grand prize of $15 million. The Lotto contest is governed by the following rules. The prize money is to be paid in 20 equal annual installments (in this case,...
-
A local distributor of t-shirts has experienced increasing demand. The table below includes monthly demand data for one year. Month JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC Demand 857 921...
-
A stone is thrown into the air at an angle above the horizontal and feels negligible air resistance. Which graph in Fig. Q3.16 best depicts the stones speed v as a function of time t while it is in...
-
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...
-
Determine whether the series converges or diverges. + 1 3n 31
-
Regan College had 30 teachers in the Business Department on January 1, 2020. During 2020, seven teachers retired, and three new teachers were hired. At the end of 2020, how many teachers were...
-
A uniform insulator of charge dq shaped like a very thin tube that is curved into semicircle of radius r, shown at near right, creates an electric field at its center of curvature at point P that has...
-
In 2020, Lucy earned $66,000 in real estate commissions. If Lucy's average commission was $6,000 per house, how many houses did Lucy sell?
-
Guy is self employed. In one year, Guy generates a gross income of $44,500. When calculating his taxes, Guy is allowed to deduct $2,500 in expenses from his gross income (the result is his 'operating...
-
Estate Finance Family Tax Plan Question 1. On January 2, 2000, Larry creates a trust with Tenleytown Trust Company as trustee. The trustee must distribute income to Susie. On January 2, 2005, the...
-
At time t = 0 s, automobile A is traveling at a speed of 18 m/s along a straight road and is picking up speed with an acceleration that has a magnitude of 3.5 m/s2 as in part a of the figure. At t 5...
-
How has the too-big-to-fail policy been limited in the FDICIA legislation? How might limiting the too-big-to-fail policy help reduce the risk of a future banking crisis?
-
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...
-
Ralph makes ( 21)/(2) batches of oatmeal cookies. Each batch makes 24 cookies. Ralph gives away ( 1)/(4) of his cookies to his class at school and ( 2)/(5) of his remaining cookies to his bus driver....
-
Create a RESTful API using Node.js and Express that performs CRUD operations on a collection of books stored in memory.
-
Find a minimum spanning tree for the weighted graph using Kruskal's algorithm. B 18 C 23 A 16 S (5 22 20 19 24 23 E D
Study smarter with the SolutionInn App