Write a function that takes three random integers and prints out their sum, prod
ID: 3663427 • Letter: W
Question
Write a function that takes three random integers and prints out their sum, product, average, maximum, and minimum values. Create a prompt asking the user to input the range the random integers should fall in (i.e. a random number between 0 and 21). Run you program three times to show that the answers are different for each run. Take a screen shot of each run and submit them along with the source file on Blackboard.
Hint: Declare the average variable as a float and figure out how to display the correct value.
PLEASE I need the right solution.
Explanation / Answer
import java.util.Random; public class RandomNumber { public static void main(String[] args) { int number1,number2,number3; int sum=0; float average; int product=1; int largest; int smallest; Random random = new Random(); number1 = random.nextInt(22); number2 = random.nextInt(22); number3 = random.nextInt(22); sum = number1+ number2+ number3; average = sum/3; product = number1 * number2 * number3; largest = number1; smallest = number1; if(number2 > largest) largest = number2; if(number3 > largest) largest = number3; if(number2Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.