Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In this lab, you will need to create a menu with two options for the user. Each

ID: 3537614 • Letter: I

Question

In this lab, you will need to create a menu with two options for the user. Each of the two options will call a game. You will need to create both games for this lab as described in your textbook. Option 1 will call the number guessing game (as described on pg 372 programming project #3). Option 2 will call the Rock Paper Scissors game (as described on pg 372 programming project #5). You can add your own creative spin as part of the solution as long as it%u2019s in the scope of the game.

Hint: You will need to read some values from the user (like how many times they want to play, the move they are taking, or guesses). Also you will need to make use of the random number generator so the computer can pick numbers, or moves. Also, refrain from solving the program using methods. Solve it using loops.

You may collaborate with other students to solve this lab, but all work is expected to be individual. Do not share code directly. It may be very helpful to solve parts of the program first in pseudocode before you write the program in Java.


Note about random numbers:

The Random class is found in the java.util package, so be sure to include import.java.util.*; in your program.

You will also need to declare a Random variable before you can create random numbers:

Random rand = new Random();

Afterwards, when you need a random number (say, a random integer between 0 and 9) we would write:

int myrandomnumber = rand.nextInt(10); // this would generate a random number 0 %u2013 9



Explanation / Answer

import java.io.*;

import java.util.*;

class game{

public static void main(String[] args){

int o = 0;

while(o != 3)

System.out.println("Enter the number which game you want to play : 1. Number Guessing Game 2. Rock paper Scissor Game 3. Exit");

Scanner E = new Scanner(System.in);

int e = E.nextInt();

switch(e){

case(1):

numbergame();

break;

case(2):

rockpaperscissor();

break;

case(3):

o = 3;

break;

default:

System.out.println("Enter valid number");

break;

}

}

static int numgame(){

System.out.println("Enter a number");

Scanner s = new Scanner(System.in);

int n = s.nextInt();

Random rand = new Random();

int j = rand.nextInt(10);

if(j == n) System.out.println("you won");

else System.out.println("you lose");

}

static int rockpaperscissor(){

}

}

you have not specified how we have to play the games , so i had guessed the number games, with it help you can make the second function or specify how to play that so i can help you again.....:)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote