im creating a java program using Jgrasp and im completely stuck on how to apply my random operator to calculate two random numbers? heres my code:
//Import Random Generator
import java.util.Random;
import java.util.*;
//Program name
class TimesTableTestTimer
{//open main
public static void main(String[] args)
{//Create while loop to restart
char Restart = 'Y';
while (Restart == 'Y' | Restart == 'y')
{
Random Generator = new Random();
//Create Random Operators
char[] chars = new char[]{'+','-','/','*'};
int r = Generator.nextInt(chars.length);
char op = chars[r];
char Answer = op;
//Create 2 Random Number Generators
float X = 1 + (int)(Math.random()*13);
float X2 = 1 + (int)(Math.random()*13);
{//Timer variables
double t1, t2, ttaken;
String Key = "";
{
System.out.println("Welcome to the Times Table Test Timer!");
System.out.println("Press the 'Enter' Key to start the Next Question");
KBInput.readString();
//Start Timer
{
for (int i = 1;i <= 4;i++)
{
t1 = (System.currentTimeMillis());
float Sum = (X + X2); //How to use the random operator instead of '+'
System.out.println(X +" ? "+X2+" = "+Sum+" "+op);
System.out.println("What is the Value of '?'...");
Answer = KBInput.readChar();
if (Answer == op)
System.out.println("Correct!");
else
System.out.println("Incorrect!");
//End Timer
t2 = (System.currentTimeMillis());
ttaken = t2-t1;
System.out.println("Your time taken is "+ttaken/1000+" Seconds.");
}//Finish sequence to loop
{//Ask to restart
System.out.println("Thank you for completing the Quiz");
System.out.println("Press 'y' to restart or any other key to exit");
Restart = KBInput.readChar();
}//Close restart option
}//Close Loop
}//Close Introduction
}//Close Variables
}//Close Randoms
}//Close While Loop
}//Close Main
ive tried looking everywhere but the forums seem to be the best place for help thanks in advanced