Okay, I've finally cracked it - I tried using a switch statement again and it's working correctly. Here's the code now:
import java.util.Scanner;
import java.util.Random;
public class...
Type: Posts; User: dk87
Okay, I've finally cracked it - I tried using a switch statement again and it's working correctly. Here's the code now:
import java.util.Scanner;
import java.util.Random;
public class...
And that's where I've been going wrong... I should've looked more closely. :o
Okay, now I'm somewhat on the right track - the numbers and operators are changing with each question, as expected....
The range of the first number is 11 to 19, while the range of the second number is 1 to 9. As far as I can see I have followed the syntax for declaring variables for random numbers to the tee, yet...
My mistake; I just remembered that it executed well if I used a single, fixed operator rather than the random operator statement (although there was still no change in the numbers)... :o
The code,...
The switch statement I tried (that is not in my code now) was as follows:
int num = (int)(2*Math.random()+1);
char operator;
// ...
switch (num) {
case 1: operator = '+';
break;
case...
Good evening. :)
I am writing a program which allows the user to input their name and then answer ten questions that take the form "1 + 2 = ?", where the ? is, of course, the answer to be given....