Write a program that asks the user how many times they want to roll two 6-sided
ID: 3641079 • Letter: W
Question
Write a program that asks the user how many times they want to roll two 6-sided dice. Once this has been obtained, repeatedly "roll" the two dice as many times as the user requested; display the values rolled by each pair. Upon each roll, calculate the value rolled (i.e., add up the two dice values). Your program should calculate and display a histogram of the frequency of the values generated. The histogram should display the bar graphs from 2-12 based upon how many times that value was rolled.Explanation / Answer
import java.util.Random; import java.util.Scanner; public class Test { public static void main(String[] args) { Random r = new Random(); Scanner sc = new Scanner(System.in); System.out.println("How many trials: "); int trials = sc.nextInt(); int[] results = new int[11]; for(int i =0; iRelated 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.