Write a FULL (not just JHUB) Java procedural program for one human player to play a "Higher or Lower" card game. In this game, each card has a value from 1.10 inclusive. There are 4 of each value in the deck, i.e., 40 cards in total. Cards are not replaced in the deck once drawn, i.e., no more than 4 of each value will be drawn. The program starts by asking the player for a target score. The game proceeds in a series of rounds with the program repeatedly drawing and showing a card from the deck to the player one at a time. Each time, it asks the player to enter "h" (higher) or "1" (lower) to guess whether the next card drawn will be higher or lower in value. The player gains a point if they guess correctly. The game continues until the player guesses incorrectly or the target score is reached. When the game ends, it prints either a "You win!" or a "Nice try, you scored .* message as illustrated below. Here are two examples of the required program behaviour: (bold is keyboard input by the player):
Write a FULL (not just JHUB) Java procedural program for one human player to play a "Higher or Lower" card game. In this game, each card has a value from 1.10 inclusive. There are 4 of each value in the deck, i.e., 40 cards in total. Cards are not replaced in the deck once drawn, i.e., no more than 4 of each value will be drawn. The program starts by asking the player for a target score. The game proceeds in a series of rounds with the program repeatedly drawing and showing a card from the deck to the player one at a time. Each time, it asks the player to enter "h" (higher) or "1" (lower) to guess whether the next card drawn will be higher or lower in value. The player gains a point if they guess correctly. The game continues until the player guesses incorrectly or the target score is reached. When the game ends, it prints either a "You win!" or a "Nice try, you scored .* message as illustrated below. Here are two examples of the required program behaviour: (bold is keyboard input by the player):
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
JAVA PLEASE
![Write a FULL (not just JHUB) Java procedural program for one human player to play a "Higher or
Lower" card game.
In this game, each card has a value from 1.10 inclusive. There are 4 of each value in the deck, i.e.,
40 cards in total. Cards are not replaced in the deck once drawn, i.e., no more than 4 of each value
will be drawn.
The program starts by asking the player for a target score. The game proceeds in a series of
rounds with the program repeatedly drawing and showing a card from the deck to the player one at
a time. Each time, it asks the player to enter "h" (higher) or "1" (lower) to guess whether the next
card drawn will be higher or lower in value. The player gains a point if they guess correctly. The
game continues until the player guesses incorrectly or the target score is reached. When the game
ends, it prints either a "You win!" or a "Nice try, you scored ..." message as illustrated below.
Here are two examples of the required program behaviour: (bold is keyboard input by the player):
Target score? 10
I drew a 5
Round 1: Higher or lower? (h/1) 1
I drew a 4
Round 2: Higher or lower? (h/1) h
I drew a 2
Nice try, you scored 1.
Target score? 40
I drew a 10
Round 1: Higher or lower? (h/1) 1
I drew a 5
Round 2: Higher or lower? (h/1) h
.. [lines omitted here for space reasons]
I drew a 2
Round 40: Higher or lower? (h/1) h
I drew a 10
You win!
Hint. you could start by considering how to design your program while first ignoring the details of
the deck (e.g., not worrying about drawing more than 4 of one value). Then extend your basic idea
to include those details in some way. One option is to design an abstract data type to track the
cards drawn so far during the game. However, you may employ any logical approach you wish.
Your program
- should use a for-loop, a while-loop, and an array (at least one of each).
- must be a procedural program. (Not an object-oriented program.)
- must not use global variables. All variables should be defined locally in a method.
You may use the following method if you wish.
/* Return a random int between e (inclusive) and bound (exclusive) */
public static int randomInt(int bound) {
Random r = new Random();
return r.nextInt(bound);
}
To gain a pass grade, your program must include meaningful use of an if-statement and a loop.
For an A grade, your program must be functionally and clearly correct, make good use of arrays,
records and methods that take arguments and/or return results, and handle erroneous inputs. It
must be designed and written in a good programming style.
For an A+ grade, your program must also make good use of at least one abstract data type, have
outstanding style and elegantly handle erroneous inputs.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ffa9dca71-cdd0-44bd-a3f0-9ac5e020fa0d%2F228dfe21-98f5-4193-944d-545b8d48f538%2Fy89pd6_processed.png&w=3840&q=75)
Transcribed Image Text:Write a FULL (not just JHUB) Java procedural program for one human player to play a "Higher or
Lower" card game.
In this game, each card has a value from 1.10 inclusive. There are 4 of each value in the deck, i.e.,
40 cards in total. Cards are not replaced in the deck once drawn, i.e., no more than 4 of each value
will be drawn.
The program starts by asking the player for a target score. The game proceeds in a series of
rounds with the program repeatedly drawing and showing a card from the deck to the player one at
a time. Each time, it asks the player to enter "h" (higher) or "1" (lower) to guess whether the next
card drawn will be higher or lower in value. The player gains a point if they guess correctly. The
game continues until the player guesses incorrectly or the target score is reached. When the game
ends, it prints either a "You win!" or a "Nice try, you scored ..." message as illustrated below.
Here are two examples of the required program behaviour: (bold is keyboard input by the player):
Target score? 10
I drew a 5
Round 1: Higher or lower? (h/1) 1
I drew a 4
Round 2: Higher or lower? (h/1) h
I drew a 2
Nice try, you scored 1.
Target score? 40
I drew a 10
Round 1: Higher or lower? (h/1) 1
I drew a 5
Round 2: Higher or lower? (h/1) h
.. [lines omitted here for space reasons]
I drew a 2
Round 40: Higher or lower? (h/1) h
I drew a 10
You win!
Hint. you could start by considering how to design your program while first ignoring the details of
the deck (e.g., not worrying about drawing more than 4 of one value). Then extend your basic idea
to include those details in some way. One option is to design an abstract data type to track the
cards drawn so far during the game. However, you may employ any logical approach you wish.
Your program
- should use a for-loop, a while-loop, and an array (at least one of each).
- must be a procedural program. (Not an object-oriented program.)
- must not use global variables. All variables should be defined locally in a method.
You may use the following method if you wish.
/* Return a random int between e (inclusive) and bound (exclusive) */
public static int randomInt(int bound) {
Random r = new Random();
return r.nextInt(bound);
}
To gain a pass grade, your program must include meaningful use of an if-statement and a loop.
For an A grade, your program must be functionally and clearly correct, make good use of arrays,
records and methods that take arguments and/or return results, and handle erroneous inputs. It
must be designed and written in a good programming style.
For an A+ grade, your program must also make good use of at least one abstract data type, have
outstanding style and elegantly handle erroneous inputs.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps

Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY