Search:

Type: Posts; User: dk87

Search: Search took 0.08 seconds.

  1. Replies
    11
    Views
    2,061

    [SOLVED] Re: Random maths operator generation

    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...
  2. Replies
    11
    Views
    2,061

    [SOLVED] Re: Random maths operator generation

    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....
  3. Replies
    11
    Views
    2,061

    [SOLVED] Re: Random maths operator generation

    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...
  4. Replies
    11
    Views
    2,061

    [SOLVED] Re: Random maths operator generation

    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,...
  5. Replies
    11
    Views
    2,061

    [SOLVED] Re: Random maths operator generation

    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...
  6. Replies
    11
    Views
    2,061

    [SOLVED] Random maths operator generation

    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....
Results 1 to 6 of 6