I need to create a program that wil prompts the user to input three numbers. Thi
ID: 672309 • Letter: I
Question
I need to create a program that wil prompts the user to input three numbers. This program should then output the numbers in nondescending order.
and it must include a parent and “main” class
“import” statement that will allow you to use the “JOptionPane” class
Create 3 variables that will allow your program to enter and store numeric numbers and initialize each.
Input a number from the dialog box and then check that the number is not equal to any of the other two numbers. If this condition fails then display an error message and exit the program.
Explanation / Answer
import java.util.*; public class lab4 { //construct an input pipeline static Scanner console = new Scanner(System.in); public static void main(String[] args) { double num1, num2, num3; double temp; System.out.print("Enter the three numbers in one line with space seperating each number: "); //input three numbers num1 = console.nextDouble(); num2 = console.nextDouble(); num3 = console.nextDouble(); System.out.println(); //make sure num1 is less than or equal to num2 if (num1 > num2) { //swap temp = num1; num1 = num2; num2 = temp; } System.out.print("The numbers in the ascending order are: "); //figure out the order of num3 and pint if (num3Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.