specs ComputeAverage A ComputeAverage Write a class called ComputeAverage what it does: asks the user to...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
specs ComputeAverage A ComputeAverage Write a class called ComputeAverage what it does: asks the user to enter three double numbers (see examples below), it uses Scanner class to read from standard input each one of the doubles entered by the user. it then prints the average of the three numbers. Suggested steps: 1. prompt the user to enter each of the three doubles by printing. 2. read each of the three doubles using a Scanner. Remember you need to declare a Scanner variable and then use it to call the nextDouble method of Scanner. 3. assign each of the three doubles to its own variable. At this point you have three different variables, each containing one of the doubles entered by the user. 4. compute the average. The average is computed by adding the three numbers and dividing by 3. 6. print the average. Use printf to print the result using only 2 digits after the decimal point. 7. you can run the application by typing: java ComputeAverage Examples (user input shown in boldface) % java ComputeAverage Please enter first double: 9 Please enter second double: 9 Please enter third double: 8 The numbers you entered are 9.0, 9.0, 8.0 The average is: 8.67 % java ComputeAverage Please enter first double: 10 Please enter second double: 12 Please enter third double: 11 The numbers you entered are 10.0, 12.0, 11.0 The average is: 11.00 % ComputeAverage.java × import java.util.Scanner; public class ComputeAverage { public static void main(String[] args) { // variable declaration double x, y, z, avg; // scanner object Scanner sc=new Scanner(System.in); System.out.print("\nPlease enter first double: "); x=sc.nextDouble(); System.out.print("\nPlease enter second double: "); y=sc.nextDouble(); System.out.print("\nPlease enter third double: "); z=sc.nextDouble(); System.out.println("\nThe numbers you entered are: // computing average avg=(x+y+z)/3; System.out.printf("\nThe average is: %.2f", avg); sc.close(); "+2); 18 19 20 1234567ORGENEN2222222222222 8 9 10 11 specs ComputeAverage A ComputeAverage Write a class called ComputeAverage what it does: asks the user to enter three double numbers (see examples below), it uses Scanner class to read from standard input each one of the doubles entered by the user. it then prints the average of the three numbers. Suggested steps: 1. prompt the user to enter each of the three doubles by printing. 2. read each of the three doubles using a Scanner. Remember you need to declare a Scanner variable and then use it to call the nextDouble method of Scanner. 3. assign each of the three doubles to its own variable. At this point you have three different variables, each containing one of the doubles entered by the user. 4. compute the average. The average is computed by adding the three numbers and dividing by 3. 6. print the average. Use printf to print the result using only 2 digits after the decimal point. 7. you can run the application by typing: java ComputeAverage Examples (user input shown in boldface) % java ComputeAverage Please enter first double: 9 Please enter second double: 9 Please enter third double: 8 The numbers you entered are 9.0, 9.0, 8.0 The average is: 8.67 % java ComputeAverage Please enter first double: 10 Please enter second double: 12 Please enter third double: 11 The numbers you entered are 10.0, 12.0, 11.0 The average is: 11.00 % ComputeAverage.java × import java.util.Scanner; public class ComputeAverage { public static void main(String[] args) { // variable declaration double x, y, z, avg; // scanner object Scanner sc=new Scanner(System.in); System.out.print("\nPlease enter first double: "); x=sc.nextDouble(); System.out.print("\nPlease enter second double: "); y=sc.nextDouble(); System.out.print("\nPlease enter third double: "); z=sc.nextDouble(); System.out.println("\nThe numbers you entered are: // computing average avg=(x+y+z)/3; System.out.printf("\nThe average is: %.2f", avg); sc.close(); "+2); 18 19 20 1234567ORGENEN2222222222222 8 9 10 11
Expert Answer:
Answer rating: 100% (QA)
Heres your code with the corrections import javautilScanner public class ComputeAverage public ... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
For the exercise in this topic, base your answers on the potentials listed in Table 6M.1 or Appendix 2B, with the exception of the reduction and oxidation of water at pH = 7: (a) What current is...
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
The Wall Street Journal Corporate Perceptions Study 2011 surveyed readers and asked how each rated the quality of management and the reputation of the company for over 250 worldwide corporations....
-
The tallest living man at the time of this writing is Sultan Kosen, who has a height of 251 cm. The shortest living man is Chandra Bahadur Dangi, who has a height of 54.6 cm. Heights of men have a...
-
A nation records the following data for 2008: exports of automobiles ($100) and corn ($150); imports of oil ($150) and steel ($75); tourist expenditures abroad ($25); private lending to foreign...
-
When uranium fissions, the fission products are radioactive because the nuclei are neutron-rich. What is the most likely decay mode for these nuclei? A. Alpha decay C. Beta-plus decay B. Beta-minus...
-
Waverly Corporation encounters the following situations: 1. Waverly collects $1,750 from a customer in 2014 for services to be performed in 2015. 2. Waverly incurs utility expense which is not yet...
-
Identify the impact on Stockholder's Equity of the error below: A company received cash from a customer for services to be provided in the future; they mistakenly credit Revenue instead of Unearned...
-
A researcher is testing a hypothesis of a single mean. The critical z value for = .05 and an one tailed test is 1.645. The observed z value from sample data is 1.13. The decision made by the...
-
Describe the idea or concept fully. Ensure that it is a significant idea or concept and not something trivial. It should be something that was new to you or interesting in some way. You must include...
-
Explain how an electric field is created around a point charge.
-
How did the reception and interpretation of classical art vary across different cultural and geographical contexts, and what strategies did artists and scholars employ to reconcile the tension...
-
Problem: How can apple ensure ethical practices with their partner manufacturers? 1.. What are the best practices in industry/other similar organizations in regards to the problem? 2. Why should...
-
What ideas can you think of to ensure that students who are graduating soon are ready for work. Write your own ideas, 1000-1200 Words
-
1) You can use any of the solutions from that problem if you think they might be helpful. Imagine a consumer - let's say Jenny - with monthly budget I = $300 who is only interested in goods x and y,...
-
Critical reading SAT scores are distributed as N(500, 100). a. Find the SAT score at the 75th percentile. b. Find the SAT score at the 25th percentile. c. Find the interquartile range for SAT scores....
-
In 2012, Lou has a salary of $54,000 from her job. She also has interest income of $1,700. Lou is single and has no dependents. During the year, Lou sold silver coins held as an investment for a...
-
John Fuji (age 37) moved from California to Washington in December 2011. He lives at 468 Cameo Street, Yakima, WA 98901. John's Social Security number is 571-78-5974 and he is single. His earnings...
-
Dr. Ivan I. Incisor and his wife Irene are married and file a joint return for 2012. Ivan's Social Security number is 477-34-4321 and he is 48 years old. Irene I. Incisor's Social Security number is...
-
Compare and contrast open market operations and reserve requirement.
-
Compare and contrast monetary policy and fiscal policy.
-
Discuss how the term market failure is understood in the context of public financial management.
Study smarter with the SolutionInn App