My question is that the program is suppose to randomly generate a addition question with two integers less than 100

this is what i have so far:

import java.util.Scanner;

public class ex3_13 {
  public static void main(String[] args) {
    // 1. Generate two random single-digit integers
    int number1 = (int)(Math.random() * 100);
    int number2 = (int)(Math.random() * 100);

    // 2. If number1 < number2, swap number1 with number2
    int temp = 0;
    if (number1 < number2)
       temp = number1;
      number1 = number2;
      number2 = temp;
    

    // 3. Prompt the student to answer “what is number1 – number2?”
    System.out.println("What is " + number1 + " + " + number2 + "? ");
    Scanner input = new Scanner(System.in);
    int answer = input.nextInt();

    // 4. Grade the answer and display the result
    if (number1 + number2 == answer)
      System.out.println("You are correct!");
    else
      System.out.println("Your answer is wrong.\n" + number1 + " + "
        + number2 + " should be " + (number1 + number2));
  }
}

I am using netbeans and it says there is no errors but when I run the program it does not show the prompt in output

what do you mean by

it does not show the prompt in output

? Do you get any output?

If you want more than 1 command to be executed "under" the if, you will need brackets:

if (number1 < number2)
..
..
..
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.