Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Dice Roll: The program simulates a two dice rolls by generating two random integers between 1 and 6. Then create a total value by adding

Dice Roll: The program simulates a two dice rolls by generating two random integers between 1 and 6. Then create a total value by adding these. The user is then prompted to guess whether the dice value is even or odd. If the user guess matches the evenness/oddness of the dice, a victory message is displayed, otherwise, a loss message is displayed.

image text in transcribed

I don't know what i am doing wrong, i want the user to enter even and odd and it shows the victory and if they enter random names like n like i did it shows them a loss. Please help.

1 import java.util.*; 2 public class NewTesting {1 public static void main(String[] args) { 4 >> Scanner input= new Scanner (System.in); int number= (int) ((Math.random() *(6) +1)); 1 System.out.println("Please guess the number wether its odd or even".+ number); ^ ^ ^ ^ ^ ^ 12 ^ ^ if (number % 2==0) {1 >> String guessinput.nextLine(); 1 guess="even"; 1 System.out.println("Victory! You guessed correctly! The answer is."+ guess);1 } .... else if (number % 2==1) {1 ... String guess= input.nextLine(); 1 ... guess="odd"; 1 >> System.out.println("Victory! You guessed correctly. The answer is.". + guess);1 } ^ ^ ^ 17 >> 18 1 21 } 22 } else 1 System.out.println("Loss! your answer is incorrect");1 & Console X NewTesting (Java Application) /Library/Java/JavaVirtual Machines/adoptopenjdk-11.jdk/Contents/Home/bin/java (Feb Please guess the number wether its odd or even 1 Victory! You guessed correctly, The answer is odd

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions

Question

what is a peer Group? Importance?

Answered: 1 week ago