a) In the Hi-Lo game, the player begins with a score of 1000. The player is prompted for the number of points to risk and a second prompt asks the player to choose either High or Low. The player’s choice of either High or Low is compared to random number between 1 and 13, inclusive. If the number is between 1 and 6 inclusive, then it is considered “low”. A number between 8 and 13 inclusive is “high”. The number 7 is neither high nor low, and the player loses the points at risk. If the player had guessed correctly, the points at risk are doubled and added to the total points. For a wrong choice, the player loses the points at risk. Create a HiLo application based on this specification. Application output should look similar to: b) Modify the application to allow the player to continue until there are 0 points left. At the end of the game, display the number of guesses the user took before running out of points. This is my code I just need part b import java.util.Random; import java.util.Scanner; public class HiLoGame { public static void main(String[] args) { final int MAX_POINT = 1000; int point = MAX_POINT; //Main() method contains rules System.out.println("High Low Game."); System.out.println("RULES."); System.out.println("1. Numbers 1 through 6 are low ."); System.out.println("2. Numbers 8 through 13 are High ."); System.out.println("3. Numbers 7 is neither high or Low."); //rules(); //Showo the rules   do { //displaying points Method displayPoints(point); int pointToRisk = enterPointsToRisk(point); String option = predictHiLo("Predict <1.High, 0. Low>: "); int min = 1; int max = 13; int computerRandomNum = randomNumgen(min, max); if (resultPoints(option, computerRandomNum)) { point += pointToRisk; System.out.println("You Won this game."); System.out.println("Now you have " + point+" to go");   } else { point -= pointToRisk; System.out.println("You Lost this game."); System.out.println("Now you have " + point+" to go"); }   System.out.println("Do you want to play agin? y/n"); Scanner in = new Scanner(System.in);   String select =in.nextLine(); if (select.equals("y")) { continue; } else {System.out.println("Bye!!"); break; } } while (point > 0);   } //rules Method /* public static void rules() { System.out.println("High Low Game."); System.out.println("RULES."); System.out.println("1. Numbers 1 through 6 are low ."); System.out.println("2. Numbers 8 through 13 are High ."); System.out.println("3. Numbers 7 is neither high or Low."); }*/ //Displaying Points Method public static void displayPoints(int point) { System.out.println("You have " +point +"number of points to risk"); } //Random Number Genertor Method public static int randomNumgen(int min, int max) { int result = 1; Random rnd = new Random(); result = rnd.nextInt(13 - 1 + 1) + 1; System.out.println("Random " +result); return result; } //enterPointsToRisk Method public static int enterPointsToRisk(int point) { System.out.println("Enter Points to risk"); Scanner in = new Scanner(System.in); int inputPoints = in.nextInt();   if (inputPoints > point) { inputPoints = point; }   return inputPoints; } //predictHiLow Method public static String predictHiLo(String i) { String result = "1"; do {   System.out.println(i); Scanner in = new Scanner(System.in); String option = in.next();   } while (!true);   return result; } //result points Method public static boolean resultPoints(String option, int guessNumber) { boolean result = false;   if (option.equalsIgnoreCase("1") && (guessNumber >= 8)&& (guessNumber <= 13)) { result = true; } else if (option.equalsIgnoreCase("0") && (guessNumber <= 6)) { result = true; }   return result; } }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

a) In the Hi-Lo game, the player begins with a score of 1000. The player is prompted for the number of points to risk and a second prompt asks the player to choose either High or Low. The player’s choice of either High or Low is compared to random number between 1 and 13, inclusive. If the number is between 1 and 6 inclusive, then it is considered “low”. A number between 8 and 13 inclusive is “high”. The number 7 is neither high nor low, and the player loses the points at risk. If the player had guessed correctly, the points at risk are doubled and added to the total points. For a wrong choice, the player loses the points at risk. Create a HiLo application based on this specification. Application output should look similar to:

b) Modify the application to allow the player to continue until there are 0 points left. At the end of the game, display the number of guesses the user took before running out of points.

This is my code I just need part b


import java.util.Random;

import java.util.Scanner;

public class HiLoGame {

public static void main(String[] args) {

final int MAX_POINT = 1000;

int point = MAX_POINT;

//Main() method contains rules

System.out.println("High Low Game.");

System.out.println("RULES.");

System.out.println("1. Numbers 1 through 6 are low .");

System.out.println("2. Numbers 8 through 13 are High .");

System.out.println("3. Numbers 7 is neither high or Low.");

//rules(); //Showo the rules

 

do {

//displaying points Method

displayPoints(point);

int pointToRisk = enterPointsToRisk(point);

String option = predictHiLo("Predict <1.High, 0. Low>: ");

int min = 1;

int max = 13;

int computerRandomNum = randomNumgen(min, max);

if (resultPoints(option, computerRandomNum)) {

point += pointToRisk;

System.out.println("You Won this game.");

System.out.println("Now you have " + point+" to go");

 

} else {

point -= pointToRisk;

System.out.println("You Lost this game.");

System.out.println("Now you have " + point+" to go");

}

 

System.out.println("Do you want to play agin? y/n");

Scanner in = new Scanner(System.in);

 

String select =in.nextLine();

if (select.equals("y")) {

continue;

}

else

{System.out.println("Bye!!");

break;

}

} while (point > 0);

 

}

//rules Method

/* public static void rules()

{

System.out.println("High Low Game.");

System.out.println("RULES.");

System.out.println("1. Numbers 1 through 6 are low .");

System.out.println("2. Numbers 8 through 13 are High .");

System.out.println("3. Numbers 7 is neither high or Low.");

}*/

//Displaying Points Method

public static void displayPoints(int point) {

System.out.println("You have " +point +"number of points to risk");

}

//Random Number Genertor Method

public static int randomNumgen(int min, int max) {

int result = 1;

Random rnd = new Random();

result = rnd.nextInt(13 - 1 + 1) + 1;

System.out.println("Random " +result);

return result;

}

//enterPointsToRisk Method

public static int enterPointsToRisk(int point) {

System.out.println("Enter Points to risk");

Scanner in = new Scanner(System.in);

int inputPoints = in.nextInt();

 

if (inputPoints > point) {

inputPoints = point;

}

 

return inputPoints;

}

//predictHiLow Method

public static String predictHiLo(String i) {

String result = "1";

do {

 

System.out.println(i);

Scanner in = new Scanner(System.in);

String option = in.next();

 

} while (!true);

 

return result;

}

//result points Method

public static boolean resultPoints(String option, int guessNumber) {

boolean result = false;

 

if (option.equalsIgnoreCase("1") && (guessNumber >= 8)&& (guessNumber <= 13)) {

result = true;

} else if (option.equalsIgnoreCase("0") && (guessNumber <= 6)) {

result = true;

}

 

return result;

}

}

 

a) In the Hi-Lo game, the player begins with a score of 1000. The player is prompted for the
number of points to risk and a second prompt asks the player to choose either High or
Low. The player's choice of either High or Low is compared to random number between
1 and 13, inclusive. If the number is between 1 and 6 inclusive, then it is considered
"low". A number between 8 and 13 inclusive is "high". The number 7 is neither high
nor low, and the player loses the points at risk. If the player had guessed correctly,
the points at risk are doubled and added to the total points. For a wrong choice, the
player loses the points at risk. Create a HiLo application based on this specification.
Application output should look similar to:
High Low Gane
RULES
1 through 6_are lou
Nunbers 8 through 13 are high
Number ? is neither high or low
You have 1000 points.
Enter points to risk: 500
Predict (1=High, 0=Low): 0
Nunber is 4
You win.
Play again? y
You have 2808 points.
b) Modify the application to allow the player to continue until there are 0 points left. At
the end of the game, display the number of guesses the user took before running out
of points.
Transcribed Image Text:a) In the Hi-Lo game, the player begins with a score of 1000. The player is prompted for the number of points to risk and a second prompt asks the player to choose either High or Low. The player's choice of either High or Low is compared to random number between 1 and 13, inclusive. If the number is between 1 and 6 inclusive, then it is considered "low". A number between 8 and 13 inclusive is "high". The number 7 is neither high nor low, and the player loses the points at risk. If the player had guessed correctly, the points at risk are doubled and added to the total points. For a wrong choice, the player loses the points at risk. Create a HiLo application based on this specification. Application output should look similar to: High Low Gane RULES 1 through 6_are lou Nunbers 8 through 13 are high Number ? is neither high or low You have 1000 points. Enter points to risk: 500 Predict (1=High, 0=Low): 0 Nunber is 4 You win. Play again? y You have 2808 points. b) Modify the application to allow the player to continue until there are 0 points left. At the end of the game, display the number of guesses the user took before running out of points.
Expert Solution
Step 1

Code in the step 2

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education