Share all news to all guy ;)

Monday, December 22, 2014


             Write a program that will ask the user to input three integer values from the keyboard. Then it will print the smallest and largest of those numbers. 

Code Here :

public static void main(String[] args) {
        int Num1, Num2, Num3, Maxi=0, Mini = 0;
        Scanner In = new Scanner(System.in);

        System.out.print("Enter Three Interger Number: ");
        Num1 = In.nextInt();
        Num2 = In.nextInt();
        Num3 = In.nextInt();

        if (Num1 > Num2 && Num1 > Num3 ) 
            Maxi = Num1;
        else if (Num2 > Num1 && Num2 > Num3)
            Maxi = Num2;
        else if (Num3 > Num1 && Num3 > Num2) 
            Maxi = Num3;
        if(Num1 <Num2 && Num1 < Num3)
            Mini = Num1;
        else if (Num2 < Num1 && Num2 < Num3)
            Mini = Num2;
        else if (Num3 < Num1 && Num3 < Num2)
            Mini = Num3;
        
        System.out.println("Maximize Number is: " + Maxi);
        System.out.println("Minimize Number is: " + Mini);
    }
}


0 comments:

Post a Comment

Popular Posts

Powered by Blogger.