Given 4 integers, output their product and their average using integer arithmetic. Ex: If the input...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Given 4 integers, output their product and their average using integer arithmetic. Ex: If the input is: 8 10 5 4 8 the output is: 1600 6 Note: Integer division discards the fraction. Hence the average of 8 10 5 4 is output as 6, not 6.75. Note: The test cases include four very large input values whose product results in overflow. You do not need to do anything special observe that the output does not represent the correct product (in fact, four positive numbers yield a negative output; wow). Submit the above for grading. Your program will fail the last test cases (which is expected), until you complete part 2 below. Also output the product and average using floating-point arithmetic. Output each floating-point value with three digits after the decimal point, which can be achieved as follows: System.out.printf ("%.3f", yourValue); Hint: Convert the input values from int to double. Ex: If the input is 810 54, the output is: 1600 6 1600.000 6.750 Note that fractions aren't discarded, and that overflow does not occur for the test case with large values. C Given 4 integers, output their product and their average using integer arithmetic. Ex: If the input is: 8 10 5 4 8 the output is: 1600 6 Note: Integer division discards the fraction. Hence the average of 8 10 5 4 is output as 6, not 6.75. Note: The test cases include four very large input values whose product results in overflow. You do not need to do anything special observe that the output does not represent the correct product (in fact, four positive numbers yield a negative output; wow). Submit the above for grading. Your program will fail the last test cases (which is expected), until you complete part 2 below. Also output the product and average using floating-point arithmetic. Output each floating-point value with three digits after the decimal point, which can be achieved as follows: System.out.printf ("%.3f", yourValue); Hint: Convert the input values from int to double. Ex: If the input is 810 54, the output is: 1600 6 1600.000 6.750 Note that fractions aren't discarded, and that overflow does not occur for the test case with large values. C
Expert Answer:
Answer rating: 100% (QA)
Java program to read 4 integers and compute and display the product and average ... 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
-
Is an action ethical simply because the action is legal? Why or why not?
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
A company is expecting to receive $5 million in foreign currency in six months. The company is concerned about the foreign currency exchange rate risk and wants to hedge its exposure. The current...
-
Mary is 30 years old and married to Mark, age 36. Mark passed away on January 30, 2021. Mark was unemployed and had no income in 2021 due to his illness. Marys seven-year-old daughter, Jenny, lived...
-
Curved panel BC is a 60ーarc, perpendicular to the bottom at C. If the panel is 4 m wide into the paper, estimate the resultant hydrostatic force of the water on the panel. R 3 m water...
-
Computer Service and Repair was started five years ago by two college roommates. The company's comparative balance sheets and income statement are presented below, along with additional information....
-
Figure P5.94 shows the mixing of two streams. The shear stress between each fluid and its adjacent walls is negligible. Why can't Bernoulli's equation be applied between points in stream 1 and the...
-
A large company has hired your friend. She confides in you about a problem with her boss. Her boss has asked customers to sign sales agreements just before the end of the year, indicating a sale has...
-
Helena is subjected to a "sneak-and-peek" search in which the search was conducted before her knowledge and before she was presented with a warrant. Helena believes her right to be protected by from...
-
Assume that Chapman Company acquired Abernethy's common stock for $490,000 in cash. As of January 1, 2017, Abernethy's land had a fair value of $90,000, its buildings were valued at $160,000, and its...
-
You purchased a property excatly 4 years ago for $11 million. At the time, the structure and improvements had an estimated value of $5 million. Since that time you have been depreciating the...
-
Arabella converted her loan to light payments which gives he an option to pay P12.000 every 2 years for 6 years. The first payment is due 4 years from now. How much is the mount of the loan if the...
-
Mary applies a force of74Nto push a box with an acceleration of0.46m/s 2 .When she increases the pushing force to80N,the box's acceleration changes to0.74m/s 2 .There is a constant friction force...
-
What are the current healthcare financing models in Argentina and what is the current state of health financing? How is money accumulated (ie. tax-based? employer-based? etc.)? What are the payment...
-
Let the yearly rate of interest be i (as a fraction, e.g. a rate of 6% would correspond to i=0.06), the amount of the principal be P, the number of years be n, the number of times per year that the...
-
An investor expects a company to enjoy 8% compound annual growth for ever, and she thinks that the appropriate rate for discounting the companys dividends would be 14%. She knows that the companys...
-
Suppose that (an) 0 and that (ban)0. What can you conclude? (bn) 0. O (bn) 1. O (bn) b. None of the other answers is correct.
-
Gordon and Lisa estimate that they will need $1,875,000 in 40 years for their retirement years. If they can earn 8 percent annually on their funds, how much do they need to save annually?
-
Emily Jackson (Social Security number 765-12-4326) and James Stewart (Social Security number 466-74-9932) are partners in a partnership that owns and operates a barber shop. The partnership's first...
-
Indicate whether each of the items listed below would be included (I) in or excluded (E) from gross income for the 2012 tax year. ________a. Welfare payments ________b. Commissions ________c. Hobby...
-
In 2012, Margaret and John Murphy are married taxpayers who file a joint tax return with AGl of $25,000. During the year they incurred the following expenses: Hospitalization insurance...
-
Someone who exposes the ethical misdeeds of others in an organization is usually called a/an _________. (a) whistleblower (b) ethics advocate (c) ombudsman (d) stakeholder
-
If a manager fails to enforce a late-to-work policy for all workersthat is, by allowing some favored employees to arrive late without penaltiesthis would be considered a violation of _________. (a)...
-
According to research on ethics in the workplace, _________ is/are often a major and frequent source of pressures that create ethical dilemmas for people in their jobs. (a) declining morals in...
Study smarter with the SolutionInn App