Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Instructions Write a Java application that reads three integers from the user using a Scanner. Then, create a separate function to calculate the sum, a

Instructions

Write a Java application that reads three integers from the user using a Scanner. Then, create a separate function to calculate the sum, a separate function to calculate the product, and a separate function to calculate the average of the numbers.

For your sum, product, and average functions:

  • Have each function 'return' their respective values.
  • Do not print the results of the sum function in the sum function. Print their results in main(). Same for the product and average functions.
  • Your 3 functions will take integers, but return doubles.
  • Users may enter any valid number, negative or not. Don't worry about checking for unreasonable input for this project.

Once the program has printed it's output, you should ask the user if they wish to run the program again. If they type "y", continue the loop and have the program repeat. If they enter anything other than "y", the program should exit. If the user quits, print a message saying the program has finished/terminated.

Ensure it is from the main function that you use use the three functions to print out the sum, product and average.

Sample Runs

Sample Program Run (user input is underlined)

Enter first number: 5

Enter Second Number: 10

Enter Third Number: 15

Sum is: 30

Product is: 750

Average is: 10

Do you wish to continue? (y/n): y

Enter first number:

Enter first number: 5

Enter Second Number: 10

Enter Third Number: 15

Sum is: 30

Product is: 750

Average is: 10

Do you wish to continue? (y/n): n

-Program Terminated -

Rubric:

  • Correct use of Scanner to read in three numbers: (2 pts)
  • Correctly created & used sum, product, average methods as described. (Each method should return a value.): (3 pts)
  • Program loops and quits from loop as described (1 pt)
  • Comments and javadoc included: (2 pts)
  • Output correctly printed from main function: (2 pts)

PLEASE DO THIS IN JAVA ! Thank You.

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

Step: 3

blur-text-image

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

Semantics In Databases Second International Workshop Dagstuhl Castle Germany January 2001 Revised Papers Lncs 2582

Authors: Leopoldo Bertossi ,Gyula O.H. Katona ,Klaus-Dieter Schewe ,Bernhard Thalheim

2003rd Edition

3540009574, 978-3540009573

More Books

Students also viewed these Databases questions

Question

What do you understand by Mendeleev's periodic table

Answered: 1 week ago

Question

Write down the circumstances in which you led.

Answered: 1 week ago