Problem

What message will the following program display if the user enters 5? What if the user e...

What message will the following program display if the user enters 5? What if the user enters 10? What if the user enters 100?

import javax.swing.JOptionPane;

public class Checkpoint

{

public static void main(String[] args)

{

String input;

int number;

input = JOptionPane.showInputDialog("Enter a number.");

number = Integer.parseInt(input);

if (number < 10)

method1();

else

method2();

System.exit(0);

}

public static void method1()

{

JOptionPane.showMessageDialog(null, "Able was I.");

}

public static void method2()

{

JOptionPane.showMessageDialog(null, "I saw Elba.");

}

}

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT