Answered step by step
Verified Expert Solution
Question
1 Approved Answer
How to comment every line of this code (just comment what the code is, not how working) The code: import java.util.Scanner; public class RandomDie {
How to comment every line of this code (just comment what the code is, not how working)
The code:import java.util.Scanner; public class RandomDie {
public static void main(String[] args) {
int die1, die2, count = 0;
String choice = "Yes";
Scanner sc = new Scanner(System.in);
System.out.println("Hey! Welcome to Tina's Dice Game.\nLet's start!");
while (choice.equalsIgnoreCase("yes")) {
die1 = (int) (Math.random() * (6)) + 1;
die2 = (int) (Math.random() * (6)) + 1;
System.out.println("Dice 1 = " + die1);
System.out.println("Dice 1 = " + die2);
System.out.println("I got " + die1 + " and " + die2 + "!");
if ((die1 + die2) % 2 == 0) {
System.out.println("Evens are better than odds!");
} else {
System.out.println("Odds are still cool!"); }
count++;
System.out.println("Do you want to play again. Enter \"yes\" to continue. ");
choice = sc.next(); }
System.out.println("The number of times the dice was thrown is: " + count);
System.out.println("Nice game!\nThanks for playing, Come play again soon!");
} }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
java Importing the Scanner class from javautil package import javautilScanner Defining a public clas...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started