Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed image

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:

Step by Step Solution

3.41 Rating (154 Votes )

There are 3 Steps involved in it

Step: 1

Image 1 Decision Tree Applicability While not directly related to membership management decision trees can be used for customer segmentation within a ... 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

Data Analysis And Decision Making

Authors: Christian Albright, Wayne Winston, Christopher Zappe

4th Edition

538476125, 978-0538476126

More Books

Students also viewed these Programming questions

Question

To become a negative ion, does an atom lose or gain an electron?

Answered: 1 week ago

Question

Give eye contact, but do not stare.

Answered: 1 week ago