Find maximum between two numbers
Sample Output
Find maximum between two numbers. Enter first number: 34 Enter second number: 50 50 is maximum number.
Java-Source Code
//package ifelsejava;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int num1, num2;
Scanner input = new Scanner(System.in);
System.out.println("Find maximum between two numbers.\n");
System.out.print("Enter first number: ");
num1 = input.nextInt();
System.out.print("Enter second number: ");
num2 = input.nextInt();
if (num1 > num2) {
System.out.println(num1 + " is maximum number.");
} else {
System.out.println(num2 + " is maximum number.\n");
}
}
}
Sample Output
Find maximum between two numbers. Enter first number: 9 Enter second number: -50 9 is maximum number.
No comments:
Post a Comment