Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Calculator, lave LVS XUNTEGISTERED le Edit Selection Find View Goto Tools Project Preferences Help untitled RunProgramjava MainApplication.java import java.util.Scanner; 2 import java.util.Random; 3 4 public

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Calculator, lave LVS XUNTEGISTERED le Edit Selection Find View Goto Tools Project Preferences Help untitled RunProgramjava MainApplication.java import java.util.Scanner; 2 import java.util.Random; 3 4 public class MainApplication{ 5 public static void main (String[] args) { 6 Casino c = new Casino(); 7 c.OrganizeNewGame(); 8 } 9 } 10 11 class Casino 12 // in programming land: we refer to stories as Requirements 13 //R001: A player walks into a casino and wants to play a game 14 // we need to create a player and a game 15 Player p1 new Player(); 16 Game g - new Gone(); 17 we must design the algorithm for how the player interacts with the Game: 19 String userAnswer: 20 Scanner sc new Scanner(System.in); //System.in is a standard input stream 21 22 public void OrganizeNewGame() { System.out.println("Welcome to our Casino: Would you like to play a Game? (y"); userAnswer sc.nextLine(); 25 26 17 (userAnswer.equals("y")) { System.out.println("let's get started"); 28 B.playGame(); 09 1.8 23 24 27 17 (useranswer.()) Susce.out.printl ("let's get started'); g.playcare(); 28 29 } else{ System.out.println("Good Bye!"); } } } class Game{ 10; final int Guess_Difference Random rand - new Random(); private int ComputerGuess 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 S 54 55 56 57 58 public void playGame() { 1/ game instructions System.out.println("Guess a number from 1 to 100"); System.out.println("And I will guess a game"); System.out.println("If your guess is withij 20 of my guess then you win, El V/computer's guess int Computerguess ComputerGuess(); System.out.println("Computer guess is " * ComputerGuess); V player's guess int Playerguess Player.Guess Number(); / determine wirinen boolean hasPlayerwonhasPlayerwon(PlayerGuess); (hasPlayerwon) { System.out.println("Congratulations! You won the game"); MainApplication.java boolean hasPlayerwon - hasPlayerwon(Player Guess); if (hasPlayerwon) { System.out.println("Congratulations! You won the game"); } else{ System.out.println("Better luck next time"); 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 // print computer and player's guess System.out.println("Computer guess: + ComputerGuess); System.out.println("Player guess: + PlayerGuess); } public int ComputerGuess() { // implement the algorithm to generate the computer's guess: //use a random Number Generato int programGuess - rand.nextInt(100) + 1; return programGuess; Il find if player has won public boolean hasPlayerwon(int playerGuess) { return Math.abs(playerGuess ComputerGuess) javac Mainfuplication.java MainApplication.java:53 error: cannot find synbol int Playerguess Player.Guess Hunber(); synbol: method Guess Number location: class Player MainApplication.java:56: error: cannot find synbol boolean hasPlayerson - has Playerson (PlayerGuess); Symbol: variable PlayerGuess location: class Gane MainApplication.java:66: error: cannot find synbol System.out.println("Player guess: PlayerGuess); synbol: variable Player Guess location class Gane 3 errors PS C:\peter> When I run above casino Game Starter CODE. get 3 errors which I mentioned above. Can you fix that

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Learning PostgreSQL

Authors: Salahaldin Juba, Achim Vannahme, Andrey Volkov

1st Edition

178398919X, 9781783989195

More Books

Students also viewed these Databases questions