Hi I need to write a program that prompts the user to input three numbers. This
ID: 672268 • Letter: H
Question
Hi I need to write a program that prompts the user to input three numbers. This program should then output the numbers in nondescending order. I started it but having issues with it. Here is what i started Wrighte a program that prompts the user to input three numbers. This program should then output the numbers in non descending order.
import java.util.*;
7 import java.lang.*;
8 import java.io.*;
9 import javax.swing.JOptionPane;
10
11 public class nonDescending
12 {
13 static Scanner console = new Scanner(System.in);
14
15 public static void main(String[] args)
16 {
17 long answer;
18 double input1;// + input2 + input3;
19 double input2;
20 double input3;
21 input1=a;
22 input2=b;
23 input3=c;
24 System.out.println(new String(new char[]{a,b,c}));
25
26 // answer = (input1)+ (input2)+(input3) //print answer
27 System.out.println("The answer is" + " " + answer);
28
29
30 if (a < b ) or (a < c); then
31
32 System.out.println(a)+(b)+(c);
33
34 //System.out.println(b);
35
36 // System.out.println(c);
37
38 if else
39
40 System.out.print.ln (input3);
41
42 System.out.print.ln (input2);
43
44 System.out.print.ln(input1;}
45
46
47 System.exit(0)
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
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.