Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you please help with this assignment! I have some of the code but it will not run. Can i have a expert look at

Can you please help with this assignment! I have some of the code but it will not run. Can i have a expert look at the assignment and have them add there own spin to it.

For this program, you will need a few variables. You should have an object of the Scanner class to read user input. You will also need two double variables: one to hold the product of all user inputs provided up to the current one (be careful about what this variable is initialized to) as well as one to hold the count of the number of user inputs. You may also need two more double variables: one to hold each individual user input before multiplying it by the previous inputs and one to hold the final geometric mean result. You will then implement a loop to continuously accept user input until the user provides a sentinel value of 0 (since the final result would always be 0, it is not useful to include a 0 in the inputs). If the user provides valid input, multiply this with the product of all previous inputs and increment the count for user inputs. After the user is done providing inputs and uses the sentinel value of 0, refer to the following equation to complete the calculations for the geometric mean: The sequence of products is the total you got while collecting user inputs. Keep in mind that getting the nth-root of a number is equivalent to raising that number to the power of 1/n. After calculating the geometric mean, print the result to the console formatted to two decimal places. For a 10 point bonus, assume these user inputs are measurements. This means the user cannot provide negative amounts. If the user does provide a negative amount, do not include this in the product and print a warning message instead.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Analysis In Microsoft Excel

Authors: Alex Holloway

1st Edition

B0CCCPKTTX, 979-8852388452

More Books

Students also viewed these Databases questions

Question

RP-7 What are some ways to reconcile conflicts and promote peace?

Answered: 1 week ago