Sunday, 5 November 2017

jav aprogram find maximum number taking three number from user



Problem 06:
Write a program that take three numbers from user and find maximum number
Discripition:
First compare 1st number with 2nd  number then 1st with 3rd and then 2nd with 3rd
Solution:
import java.util.*;
public class Message {
 public static void main(String[] args) {
  Scanner input= new Scanner(System.in);
   System.out.println("Enter the frist  number");
    int num1=input.nextInt();
    System.out.println("Enter the Second  number");
    int num2=input.nextInt();
  System.out.println("Enter the Second  number");
    int num3=input.nextInt();
   if((num1>num2)&&(num1>num3))
        System.out.println("The maximum number is "+num1);
   if((num2>num1)&&(num2>num3))
        System.out.println("The maximum number is "+num2);
   if((num3>num2)&&(num3>num1))
         System.out.println("The maximum number is "+num3);
 }}
Output:
                


No comments:

Post a Comment