Wednesday, June 16, 2021

Take three numbers from the user and print the greatest number (Java) (181)

package com.company;
import java.util.Scanner;
public class Program18 {
public static void main(String[] args) {
Scanner put = new Scanner(System.in);
System.out.println("please enter a first number:");
int a = put.nextInt();
System.out.println("please enter a second number:");
int b = put.nextInt();
System.out.println("please enter a third number:");
int c = put.nextInt();
if (a > b && a>c) {
System.out.print("maximum number is: ");
System.out.println(a);
}
else if (b > a && b > c) {
System.out.print("maximum number is: ");
System.out.println(b);
}
else if (c > b && c > a) {
System.out.print("maximum number is: ");
System.out.println(c);
}
else {
System.out.print("you entered the same numbers: ");
}
}

} 

No comments:

Post a Comment