Help me to write the code! Please upload the document so I can copy it. : ) Here is the text from Last screenshot import

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Help me to write the code! Please upload the document so I can copy it. : ) Here is the text from Last screenshot import

Post by answerhappygod »

Help me to write the code!
Please upload the document so I can copy it. : )
Help Me To Write The Code Please Upload The Document So I Can Copy It Here Is The Text From Last Screenshot Import 1
Help Me To Write The Code Please Upload The Document So I Can Copy It Here Is The Text From Last Screenshot Import 1 (113.72 KiB) Viewed 31 times
Here is the text from Last screenshot
import java.util.*;
public class MatchingGameShell
{
public static void main(String[] args)
{
//fill in the code for each line of the provided comment
//create a Scanner object
//declare a string variable and assign "" to it . call this
variable answer
String answer = "";

while (!answer.equalsIgnoreCase("q"))
{
// call the description method
//prompt the user to enter their name , store their name in a
variable

//display the hello message(refer to the output )

//call the play method and pass the Random object that you created
to it

//display the message "Hit enter to let another person play or
enter Q to
quit the program"
//store the user's input in the answer variable. all you need to do
is
answer = kb.nextLine(), assuming your scanner object is kb

}
//display a good by message

}
public static int getRand(Random rand)
{
//your code
return 0;// must change this line
}
public static void play(Random rand)
{


Scanner kb = new Scanner(System.in);
int total = 0;
String answer = "";
int n1= 0, n2 = 0, n3 = 0;
while(!answer.equalsIgnoreCase("q"))
{
//call the method getRand(rand) three times and store the result in
the
variable n1, n2, n3
//display the generated random numbers

int match = match(n1,n2,n3);
if (match == 2)
{
//add 100 to the total total = total + 100;
//display the proper message
System.out.println("You got two matches, you won 100
dollars");
}
else if( match == 3)
{
//add 300 to the total
// display the proper message
}
else
//display the proper message

System.out.print("\nHit enter to continue or press q/Q to quit
");
answer = kb.nextLine();


}
System.out.println("\nTotal amount you won: " + total);
System.out.println("\n");

}
public static int match(int n1, int n2, int n3)
{
//your code with conditional stamnets
return 0;//must modify
}
public static void description()
{
//your code to display the descritpion
}
}
Sunday (19) Tw\ (19) You What Doura String c Ass X Launch - Вход A Ges: Coul D Diablo Barpy FASE esus.instructure.com/courses/93174/assignments/1520979?module_item_id-4380786 Assi #2 Number matching game Page < Objective In this assignment you will be practicing while loop, String class, Random class and Scanner class. Problem Design and implement an application that simulates the number matching game in which three numbers. between 1-9 inclusive are randomly generated and printed side by side. Your program examines the three generated numbers based on the following if the three generated numbers are matching then the person will win 300 if two of the three random numbers are matching then the person will win 100 • no matching number, the person will not win anything your program must keep track of the amount money the person has gained throughout playing the game and displays the total amount at the end. Here is a partial sample output HH FE ← C number matching.docx 80°F Sunny OL lorena D kill me Download 1 Encktp Пошук Enktp + G A Alternative formats of 3 o ZOOM ALê Info SO рус + обновить X Close ✓ ☎ 00 * 2:29 PM 6/5/2022 5
Sunday (19) Tw\ (19) You What String c Assi X ✔ Launch - Вход Doura esus.instructure.com/courses/93174/assignments/1520979?module_item_id-4380786 Assi #2 Number matching game ← C number matching.docx 80°F Sunny COME D Diablo Barpy FASE Welcome to number matching game. I will generte three randon numbers for you. If two 1.. of the numbers match you win 100, if you get three matching numbers you win 300 dollars What is your name: Alex Hello Alex lets start playing You got: 8 5 7 Sorry no match Hit enter to continue or press q/Q to quit You got: 9 38 Sorry no match Hit enter to continue or press q/Q to quit You got: 699 You got two matches, you won 100 dollars Hit enter to continue or press q/Q to quit You got: 39 1 Sorry no match Hit enter to continue or press q/Q to quit You got: 998 You got two matches, you won 100 dollars Hit enter to continue or press q/Q to quit q Total amount you won: 200 For a compete sample output refer to the provided file called number matching sample output.txt Requirements 1. Your program should allow another player to start the game once the first player is done H C FE G A GODIN lorena D kill me Download Page < Encktp Пошук Enktp + G A Alternative formats > of 3 o ZOOM ALê SOF обновить X Close ✓ Info + рус ☎ 00 * 2:29 PM 6/5/2022 5
Sunday (19) Tw\ (19) You What String c Assi X ✔ Launch - Вход A GST COML D Diablo Barpy FASE Doura esus.instructure.com/courses/93174/assignments/1520979?module_item_id-4380786 Assi #2 Number matching game Page < Requirements 1. Your program should allow another player to start the game once the first player is done playing. Refer to the sample output 2. Feel free to be creative by adding more features to the program 3. 4. make sure to provide the block comments for each method describing what the method does solutions with just the main method will get partial credit. You must have multiple methods in your program 5. A java shell has been provided. However, feel free to write the program the way you want by not using my shell. make sure to provide methods 6. Your program should include the following methods or similar methods if you are not using the provided shell. Create a java class and implement the following methods in the given order. • public static int getRandNum (Random rand): This method gets a Random object as its parameter and returns a random number between 1-9. The code to generate a random number between 1-9 is: int x-rand nexrint(9) + 1 • public static int match (int n, int n2, int n3): This method gets three numbers as its parameters, compares the numbers. if the three numbers are the same retums 3, if the two numbers out of three are the same returns 2, otherwise should return 0. you need couple condition statements to cover all different combinations, for example, one of the conditions is: H O FE ← C number matching.docx 80°F Sunny lorena D kill me Download 2 Erektp Пошук Enktp + G A Alternative formats > of 3 o Info ZOOM SOF обновить X Close ✓ PVC + ☎ 00 * 2:29 PM 5 6/5/2022
Sunday (19) Tw\ (19) You What Doura String c Ass X Launch - Вход esus.instructure.com/courses/93174/assignments/1520979?module_item_id-4380786 Assi #2 Number matching game A Ges: Coul D Diablo Barpy FASE Page < 5. A java shell has been provided. However, feel free to write the program the way you want by not using my shell. make sure to provide methods 6. Your program should include the following methods or similar methods if you are not using the provided shell. Create a java class and implement the following methods in the given order. public static int getRandNum (Random rand): This method gets a Random object as its parameter and returns a random number between 1-9. The code to generate a random number between 1-9 is: int x-rand nexrInt(9) + 1 • public static int match (int n, int n2, int n3): This method gets three numbers as its parameters. compares the numbers. if the three numbers are the same retums 3, if the two numbers out of three are the same returns 2, otherwise should return 0. you need couple condition statements to cover all different combinations, for example, one of the conditions is: if(n1n2 && n2 = n3) return 3; • public static void description (): This method displays the description of the program. refer to the sample out. public static void play (Random rand): for the description of this method refer to the provided shell. implement the code based on the given pseudocode. public static void main (String[] args): for the description refer to the provided java shell. Implement the code based on the given pseudocode H F ← C number matching.docx 80°F Sunny lorenz D kill me Download 3 Erekt Пошук Enktp + G A Alternative formats > of 3 o SOF обновить X Close ✓ Info ZOOM + PVC ☎ 00 * 2:29 PM 5 6/5/2022
Page < import java.util."; public class MatchingGameShell ( public static void main(String[] args) C //fill in the code for each Line of the provided comment //create a Scanner object //declare a string variable and assign "" to it. call this variable answer String answer": while (!answer.equalsIgnoreCase("q")) }" { // call the description method //prompt the user to enter their name, store their name in a variable //display the hello message(refer to the output) //call the play method and pass the Randon object that you created to it //display the message "Hit enter to let another person play or enter Q to quit the program" //store the user's input in the answer variable. all you need to do is answer kb.nextLine(), assuming your scanner object is kb //display a good by message } public static int getRand (Random rand) ( //your code return 0;// must change this line 3 public static void play (Random rand) C Scanner kb new Scanner (System.in); int total = 0; String answer= ""; int ni- , n28, n3 0; while(!answer.equalsIgnoreCase("q")) { //call the method get Rand (rand) three times and store the result in the variable ni, n2, 13 //display the generated random numbers int match match(n1, n2, n3); if (match 2) { //add 100 to the total total total 100; //display the proper message System.out.println("You got two matches, you won 100 dollars"); } else if( match 3) { //add 300 to the total // display the proper message 1 of 2 O ZOOM +
else //display the proper message System.out.print("\nHit enter to continue or press q/Q to quit "); answer kb.nextLine(); System.out.println("\nTotal amount you won: total): System.out.println(" } public static int match(int n, int n2, int n3) //your code with conditional stamnets return 0;//must modify } public static void description() ( //your code to display the descritpion Page < O ZOOM
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply