Your little brother is having trouble with arithmetic-particularly, his addition and multiplication of positive integers. Your...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Your little brother is having trouble with arithmetic-particularly, his addition and multiplication of positive integers. Your parents realize that after taking a few weeks of your Java programming course, you could potentially write a computer game program that would allow him to practice his arithmetic skills. (Before reading on, we'd recommend looking at the sample program output below to get a feel for what's happening in the game.) Write a program, CoolArithmeticGames.java. Basically, the game works like this: The user has a score that starts at zero. Each time they play a round of the game, they are asked some addition or multiplication questions. If they get all the questions correct in the round, they gain points. If they get even one question wrong, they immediately lose the round and gain 0 points. The game gradually gets harder as the user wins more. The user will be able to see their score between rounds, as well as their current and longest winning streak, in the hall of fame. The number of questions the user is asked each round is equal to ceiling (score/5) + 1. "Ceiling" means take the result of the expression and round up to the nearest integer, even if the fractional part isn't > 0.5. This can be accomplished In Java using Math.ceil(), but note that it returns a double, which you may need to cast to an integer later on. For example: If score is 0, ask 0+1=1 questions, since 0/5 is 0 which is already an integer If score is 1, ask 1+1 2 questions, since ceil(1/5)=1 If score is 2, ask 1+1 2 questions If score is 5, ask 1+1 = 2 questions, since cell(5/5) = 1 which is already an integer If score is 6, ask 2+1 3 questions, since ceil(6/5)=2 If score is 21, ask 5+1 6 questions, since ceil(21/5) - 5 The user chooses whether they are asked addition or multiplication questions each round. Multiplication rounds give double the points of addition rounds. They also choose the maximum number that can appear as the two randomly generated numbers; however, they must choose a max number that is greater than their current score. The minimum for each number is 0, making the random interval [0, maxNumber]. With this max number, the number of questions to be asked, and whether or not the game is addition or multiplication, you will pass these arguments to a method you write called arithGame(), which returns the points earned in that round. Once again, if the user gets all questions right in addition mode, points gained will be the number of questions asked that round. In multiplication mode, points gained will be double the number of questions asked on a win. If they lose, the round should Immediately end and they gain no points. Other than playing and quitting the game, on the main menu the user can also choose to see the hall of fame. This will display their score, their current round win streak and whether they're still on a streak, and their longest ever round win streak. Importantly, for this project, you must validate all menu option choices entered by the user. For example, on the main menu, they must choose either 1, 2, or 3, or else they will be asked to enter a valid input. We haven't taught you how to deal with the user entering something other than a number, so you can assume they only enter integers. However, you must make sure that that integer is a valid choice on their current menu. Sample program output User input in bold and italics. Welcome to CoolArithmetics! Please make a selection from the following: 1. Play Arithmetic Game. 2. View Hall of Fame. 3. 2 Quit. ----- Hall of Fame ----- Your score: 8 Current round win streak: 0 Longest round win streak: Please make a selection from the following: 1. Play Arithmetic Game. 2. View Hall of Fame. 3. Quit. 1 Would you like (1) addition or (2) multiplication? 1 Enter the maximum number, which must be greater than your score (8): 1 1+1-2 You got 1 points for winning! Please make a selection from the following: 1. Play Arithmetic Game. 2. View Hall of Fame. 3. Quit. 1 Would you like (1) addition or (2) multiplication? 1 Enter the maximum number, which must be greater than your score (1): 2 8+1-1 1+8-1 You got 2 points for winning! Please make a selection from the following: Your little brother is having trouble with arithmetic-particularly, his addition and multiplication of positive integers. Your parents realize that after taking a few weeks of your Java programming course, you could potentially write a computer game program that would allow him to practice his arithmetic skills. (Before reading on, we'd recommend looking at the sample program output below to get a feel for what's happening in the game.) Write a program, CoolArithmeticGames.java. Basically, the game works like this: The user has a score that starts at zero. Each time they play a round of the game, they are asked some addition or multiplication questions. If they get all the questions correct in the round, they gain points. If they get even one question wrong, they immediately lose the round and gain 0 points. The game gradually gets harder as the user wins more. The user will be able to see their score between rounds, as well as their current and longest winning streak, in the hall of fame. The number of questions the user is asked each round is equal to ceiling (score/5) + 1. "Ceiling" means take the result of the expression and round up to the nearest integer, even if the fractional part isn't > 0.5. This can be accomplished In Java using Math.ceil(), but note that it returns a double, which you may need to cast to an integer later on. For example: If score is 0, ask 0+1=1 questions, since 0/5 is 0 which is already an integer If score is 1, ask 1+1 2 questions, since ceil(1/5)=1 If score is 2, ask 1+1 2 questions If score is 5, ask 1+1 = 2 questions, since cell(5/5) = 1 which is already an integer If score is 6, ask 2+1 3 questions, since ceil(6/5)=2 If score is 21, ask 5+1 6 questions, since ceil(21/5) - 5 The user chooses whether they are asked addition or multiplication questions each round. Multiplication rounds give double the points of addition rounds. They also choose the maximum number that can appear as the two randomly generated numbers; however, they must choose a max number that is greater than their current score. The minimum for each number is 0, making the random interval [0, maxNumber]. With this max number, the number of questions to be asked, and whether or not the game is addition or multiplication, you will pass these arguments to a method you write called arithGame(), which returns the points earned in that round. Once again, if the user gets all questions right in addition mode, points gained will be the number of questions asked that round. In multiplication mode, points gained will be double the number of questions asked on a win. If they lose, the round should Immediately end and they gain no points. Other than playing and quitting the game, on the main menu the user can also choose to see the hall of fame. This will display their score, their current round win streak and whether they're still on a streak, and their longest ever round win streak. Importantly, for this project, you must validate all menu option choices entered by the user. For example, on the main menu, they must choose either 1, 2, or 3, or else they will be asked to enter a valid input. We haven't taught you how to deal with the user entering something other than a number, so you can assume they only enter integers. However, you must make sure that that integer is a valid choice on their current menu. Sample program output User input in bold and italics. Welcome to CoolArithmetics! Please make a selection from the following: 1. Play Arithmetic Game. 2. View Hall of Fame. 3. 2 Quit. ----- Hall of Fame ----- Your score: 8 Current round win streak: 0 Longest round win streak: Please make a selection from the following: 1. Play Arithmetic Game. 2. View Hall of Fame. 3. Quit. 1 Would you like (1) addition or (2) multiplication? 1 Enter the maximum number, which must be greater than your score (8): 1 1+1-2 You got 1 points for winning! Please make a selection from the following: 1. Play Arithmetic Game. 2. View Hall of Fame. 3. Quit. 1 Would you like (1) addition or (2) multiplication? 1 Enter the maximum number, which must be greater than your score (1): 2 8+1-1 1+8-1 You got 2 points for winning! Please make a selection from the following:
Expert Answer:
Answer rating: 100% (QA)
Image 1 Decision Tree Applicability While not directly related to membership management decision trees can be used for customer segmentation within a ... View the full answer
Related Book For
Data Analysis and Decision Making
ISBN: 978-0538476126
4th edition
Authors: Christian Albright, Wayne Winston, Christopher Zappe
Posted Date:
Students also viewed these programming questions
-
In 2023, Capstone Inc. introduced a new line of televisions that carry a two-year warranty against manufacturer\'s defects. Based on past experience with similar products, warranty costs are expected...
-
Two candidate single-stage rockets are proposed for a specified mission with a required V = 10,000 m/s and a payload mass of 10,000 kg. The first rocket (rocket A) is a chemical rocket. The second...
-
List three specific parts of the Case Guide, Objectives and Strategy Section (See below) that you had the most difficulty understanding. Describe your current understanding of these parts. Provide...
-
Write out the equation for the following chemical reaction and balance it. Solid potassium chlorate, KCIO3, decomposes to form solid potassium chloride and diatomic oxygen gas. What is the...
-
Who might a plant accountant consult with when establishing direct labor quantity or rate standards?
-
Give an example of explicit costs, implicit costs, fixed costs, variable costs, opportunity costs, sunk costs, and intangible costs for each of the following types of entities: (a) An industrial...
-
Intelligencia Inc. was incorporated as a research and development company in the biotechnology industry. The company incurred the following costs relating to various intangible assets: 1. During the...
-
Fly-By-Night Couriers is analyzing the possible acquisition of Flash-in-the-Pan Restaurants. Neither firm has debt. The forecasts of Fly-By-Night show that the purchase would increase its annual...
-
Q1) Suppose a firm has 36.20 million shares of common stock outstanding at a price of $25.21 per share.The firm also has 483000.00 bonds outstanding with a current price of $1,173.00. The outstanding...
-
You are discussing your 401(k) with Dan Ervin when he mentions that Sarah Brown, a representative from Bledsoe Financial Services, is visiting East Coast Yachts today. You decide that you should meet...
-
4. Yes sale and decides to exercise the fair value option with respect to that investment, the presentation of said investment in the Balance Sheet: a. It will be at fair value and unrealized gains...
-
What is Corporate Social Responsibility?What are the benefits of CSR, and why do you think an entity should make CSR an integral part of corporate strategy?
-
During its accounting period, a company generated direct material costs that represented 2/3 of the total production cost, with the total prime cost being $1,830,000.00 and the conversion cost being...
-
1. Briefly describe growth vs. value investing. 2. What is credit risk? 3. Briefly describe why some bonds have higher yields/rates than other bonds?
-
Levi Company had sales of Php576,000 and variable costs of Php324,000. Fixed costs amount to Php96,000 from an expected production of 7,200 units. If the company expects to increase its sales by 960...
-
There are 10 M&Ms of which 6 are green, in a bowl.You select 2 of them and eat each after it is selected.Is this a binomial experiment?Why or why not?
-
Describe the language and some of the strings accepted by the following Automaton. List some of the strings generated by the Automaton. 0 9 0 q 0
-
Describe a group you belong or have belonged discuss the stages of group development and suggest how to improve the group effectiveness by using the group development model.
-
The file S04_62.xlsx contains the joint probability distribution of recent weekly trends of two particular stock prices, P1 and P2. a. Are P1 and P2 independent random variables? Explain why or why...
-
A manufacturing plant produces two distinct products, A and B. The cost of producing one unit of A is $18 and that of B is $22. Assume that this plant incurs a weekly setup cost of $24,000 regardless...
-
The Undergraduate Data sheet of the file P10_21.xlsx contains information on 101 undergraduate business programs in the U.S., including various rankings by Business Week. Use multiple regression to...
-
A perfectly competitive firm seeking to maximize its profits would want to maximize the difference between a. its marginal revenue and its marginal cost. b. its average revenue and its average cost....
-
If a perfectly competitive firms marginal revenue exceeded its marginal cost, a. it would cut its price to sell more output and increase its profits. b. it would expand its output but not cut its...
-
How do we determine whether a firm is making zero economic profits?
Study smarter with the SolutionInn App