# Thread: I need this game!!!

1. Member
Join Date
Apr 2010
Posts
7
Rep Power
0

## I need this game!!!

Problem Description:
Write a game to help users to improve their arithmetic calculation skills. The aim of the game is to solve maximum number of questions correctly in a limited time. The game must generate random arithmetic expressions of two and three operations with random integer operands and asks the user the answer. If the user correctly writes the answer, the program generates the next random question until the time finishes. Use the following rules to implement your program.

1. Give initial time of 1 minute (increase the total time by 5 seconds if 5 questions in a row were correct).
2. Implement two levels:
a) First level uses one operation with two operands only, e.g. 5+3 ?
b) Second level uses two operations with three operands , e.g. 20 / 4 + 5 ?
3. At the end of the program calculate and show the score by grading total number of correctly answered questions. The program also must display the total time that is elapsed and number of correct answer/questions. You can provide motivational messages such as in the sample run that is provided.
4. According to the score of the user, put a threshold to decide whether the user can advance to the next level or repeat the current level.
5. At the end of game ask the user if he wants to repeat the level, advance to the next level (if he has enough points), or quit the program.
Here is a sample run of the program:

2. Member
Join Date
Apr 2010
Posts
7
Rep Power
0
IT MUST LOOK LIKE ;

Welcome to Arithmetic’s Exercise Program
Answer as many questions in total 60 seconds.
You get 5 seconds bonus if you answer 5 questions in a row.
Use java arithmetic precedence rules!
Input ‘q’ to quit or any key to start:

1. 5+6*9 = 59 … Correct
2. 2-6*0 = 2 … Correct
3. 3/8+5 = 5 … Correct
4. 8/2-4 = 0 … Correct
5. 9*12+0 = 96 … Correct (5 seconds added)
6. 52-12+13 = 51 … Wrong
7. 5+1*9 = 59 … wrong
8. 2-2*0 = 2 … wrong
9. 3/1+5 = 5 … wrong
Time finished!

You are as fast as a turtle!
You answered 5 questions correctly out of 9 in 65 seconds.

You can not advance to the next level
Input ‘q’ to quit or any key to restart:

3. You have essentially posted your assignment and shown no work, shown no effort as if you want someone here to do this for you. Well, it ain't going to happen. By posting this way, you are risking cheating yourself out of the education you gain by doing this yourself and learning as you are doing, and none of us wish to deprive you of this benefit. We will be happy to answer specific questions you may have regarding problems with your code, but first you need to show some initiative and effort.

Best of luck.
Last edited by Fubarable; 04-10-2010 at 02:55 PM.

4. Member
Join Date
Apr 2010
Posts
7
Rep Power
0
Of course I do not want someone to do this assigment for me! I just need some trick if anyone knows! thats all I want! this is a kind of hard job, so nobody wants to do it!

5. Member
Join Date
Apr 2010
Posts
7
Rep Power
0
import java.util.Scanner;
public class TheGame {
public static void main (String [] args){
int count= 0;
while (count<100){
int number1 = (int)(Math.random()* 10);
int number2 = (int)(Math.random()* 10);
Scanner input = new Scanner(System.in);
System.out.print("What is " + number1 + " + " + number2 + "?");
System.out.println(number1+ " + " + number2 + " = " + answer + " is " + (number1+number2 == answer));
count++;
long endTime = System.currentTimeMillis();
long testTime= endTime - startTime;
System.out.println ("Correct count is " + correctCount + "\nTest time is " + testTime /1000 + "seconds\n" + output);
}
}
}

and I did some codes like that but it does not work. I could not manage the time code:S

6. Originally Posted by holy crab
Of course I do not want someone to do this assigment for me! I just need some trick if anyone knows! thats all I want! this is a kind of hard job, so nobody wants to do it!

7. Have you worked with creating methods other than the main, because you're going to have to do this to solve this assignment. Your best bet is to break the problem down into steps and try to solve each step in isolation.

for e.g.,
Pseudo-code
Java Code:
```begin
start count-down timer
while time remaining > 0
show level-1 question
if correct: increase fiveInRowCorrect int by 1, else fiveInRowCorrect = 0
if fiveInRowCorrect >= 5, then time remaining += 5 seconds and fiveInRowCorrect = 0
end while
end```

8. Member
Join Date
Apr 2010
Posts
7
Rep Power
0
thanks for ur help, I have last question now; how can I divide the game two different levels

9. Originally Posted by holy crab
thanks for ur help, I have last question now; how can I divide the game two different levels

i would write a method that returns questions with two operands for the easy part and the same method that returns questions with three operands, depending what level is selected. all the other code for the game is the same.

this game is almost the same game in dr. kawashima's brain training for nindendo ds. are here any awt/swing programmers that are interested in writing some parts of Dr Kawashima's Brain Training: How Old Is Your Brain?

10. Member
Join Date
Apr 2010
Posts
7
Rep Power
0
Thank you for ur help, I will try to do it, then will show u again..

11. Member
Join Date
Apr 2010
Posts
7
Rep Power
0
import java.util.Scanner;
public class TheGame {

public static void main (String [] args){
final int Number_of_Questions=9;
int trueCount=0;
int count=0;
long startTime=System.currentTimeMillis();
while (count<10){
int number1 = (int)(Math.random()* 10);
int number2 = (int)(Math.random()* 10);
Scanner input = new Scanner(System.in);
System.out.print("What is " + number1 + " + " + number2 + "?");
trueCount++;

System.out.println(number1+ " + " + number2 + " = " + answer + " is " + (number1+number2 == answer));
count++; }

long endTime = System.currentTimeMillis();
long testTime = endTime - startTime;

System.out.println("You asnwered " + trueCount + " questions correctly " + "\n in " + testTime / 1000 + " seconds\n");

}
}

The last view of my project is like that now! but I can not manage the time ; for example I have to give a limited time but how? and also how can I add extra 5 seconds for every 5 correct questionss??? :S:S

thankss

12. Senior Member
Join Date
Dec 2008
Posts
526
Rep Power
0
Originally Posted by holy crab

The last view of my project is like that now! but I can not manage the time ; for example I have to give a limited time but how? and also how can I add extra 5 seconds for every 5 correct questionss??? :S:S

thankss
use java.util.TimerTask or java.util.Timer to solve it ;)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•