I haven't done any coding in about 2 months. My Computer Science teacher gave us a project to create a math game using a GUI or Menu. It has to have the following options for the user: Adding integers, subtracting integers, multiplying integers, dividing integers, adding decimals, subtracting decimals, multiplying decimals, square root of perfect square, cubic root of perfect cubes, power of an integer, area of a rectangle, perimeter of a rectangle. It should also store the student's name and grade on the game. I don't have a clue on how to start this so can someone help me out?
2 replies to this topic
#1
Posted 15 May 2011 - 06:48 PM
|
|
|
#2
Posted 16 May 2011 - 03:33 AM
Console example with only "+" and "-";
You just need a lot more operations and a GUI :P
char[] operations = {'+', '-'};
Scanner scanner = new Scanner(System.in);
Random random = new Random();
while(true){
char operation = operations[random.nextInt(2)];
int a = random.nextInt(10);
int b = random.nextInt(10);
int result;
switch(operation){
case '+' : result = a + b; break;
case '-' : result = a - b; break;
}
System.out.println(a + " " + operation +" " + b " = ?");
int input = scanner.nextInt();
scanner.nextLine(); //clear \n in buffer
if(input == result){
System.out.println("correct.\n");
} else {
System.out.println("incorrect.\n");
}
}
You just need a lot more operations and a GUI :P
#3
Posted 16 May 2011 - 07:09 AM
Thanks for the help! I will definitely use this!
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









