Given three numbers, write a program that outputs the number withthe greatest va
ID: 3615365 • Letter: G
Question
Given three numbers, write a program that outputs the number withthe greatest value among the three. Use the conditional ?: (HINT:You will need to use two sets of ?: to solve this). For example,given the numbers 10, 23 and 5, your program should output,number 1 = 10
number 2 = 23
number 3 = 5
The highest number is = 23
Explanation / Answer
please rate - thanks import java.util.*; public class untitled { public static void main(String[] args) {int num1,num2,num3,high; Scanner in=new Scanner(System.in); System.out.print("Enter number 1: "); num1=in.nextInt(); System.out.print("Enter number 2: "); num2=in.nextInt(); System.out.print("Enter number 3: "); num3=in.nextInt(); high=num1>num2?num1:num2; high=num3>high?num3:high; System.out.println("number 1 = "+num1); System.out.println("number 2 = "+num2); System.out.println("number 3 = "+num3); System.out.println("The highest number is ="+high); } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.