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
-
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...
-
Two charges are fixed in place on the x-axis as shown. The charge at x = 0 is negative and has magnitude q = 2 Coulombs (1 Coulomb = 10-6 Coulombs). The charge at x = d, (d = +12 cm), is positive and...
-
Find the hyperbolic function g(t) = a cosh t + b sinh t that best approximates the data in Exercise 5.5.41. Data From 5.5.41 Given the values construct the trigonometric function of the form g(t) = a...
-
When the plaintiff was 16, he was employed by Kmart as a cashier. At the end of his training, he was required to read Kmarts policy agreement, which included an agreement to submit all employment...
-
Sarah OHann enjoyed taking her first auditing course as part of her undergraduate accounting program. While at home during her semester break, she and her father discussed the class and it was clear...
-
One way in which economic growth is measured apart from GDP is in Purchasing Power Parity (PPP) terms. The Big Mac Index is the PPP concept applied to the cost of a Big Mac in different countries....
-
Using the predictions made by the model on the "Prediction data (this year, active donors)" data set, if the Gabriel Hansen Foundation did not change its direct marketing strategy at all, and sent...
-
Sam buys a used Camry from Best Motors, paying $2,000 down and agreeing to pay off the balance in thirty-six payments of $400 each. The terms of the agreement call for Sam to make a payment on or...
-
During a de-orbit burn, a pre-calculated V (delta V, change in velocity) will be used to decrease the Orion MPCV's altitude. The Orion MPCV's Orbital Maneuvering System (OMS) engines provide a...
-
Assume that the risk-free rate of interest is 4% and the expected rate of return on the market is 16%. A share of stock sells for $63 today. It will pay a dividend of $3 per share at the end of the...
-
When planning and managing a meeting, several tasks can and should be delegated. List the types of tasks that could fall into this category and the benefits associated with delegating these tasks to...
-
Identify, analyze, and develop tesla response plans to project risks in supply chain management. Describe the main risks of tesla to the effective delivery of a project. Explain and critique risk...
-
On December 19, 2022, a major flood destroyed the merchandise inventory of the Solid Glass Door Company. In a waterproof secure safe were the company's records with the following information: Solid...
-
Write about Real-world applications of the following tests, phenol red broth test, oxidase test, citrate test, phenylalanine deaminase test, starch hydrolysis test, bacitracin, novobiocin, optochin...
-
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...
-
Let \(X_{1}, \ldots, X_{n}\) be a set of independent and identically distributed random variables from a distribution \(F\) that has parameter \(\theta\). Let \(\hat{\theta}_{n}\) be an unbiased...
-
Consider a sequence of random variables \(\left\{X_{n}ight\}_{n=1}^{\infty}\) where \(X_{n}\) has probability distribution function \[f_{n}(x)= \begin{cases}{[\log (n+1)]^{-1}} & x=n \\ 1-[\log...
-
Consider an arbitrary probability measure space \((\Omega, \mathcal{F}, P)\) and let \(X_{r}\) be the collection of all possible random variables \(X\) that map \(\Omega\) to \(\mathbb{R}\) subject...
Study smarter with the SolutionInn App