GTU OOP Program - 5

5). Write a program that prompts the user to enter three integers and display the integers in decreasing order.

import java.util.Scanner;

class Program_05 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("Enter First number : ");
        int num1 = input.nextInt();
        System.out.print("Enter Second number : ");
        int num2 = input.nextInt();
        System.out.print("Enter Third number : ");
        int num3 = input.nextInt();

        int temp;

        if (num1 < num2 || num1 < num3) {
            if (num1 < num2) {
                temp = num1;
                num1 = num2;
                num2 = temp;
            }
            if (num1 < num3) {
                temp = num3;
                num3 = num1;
                num1 = temp;
            }
        }
        if (num2 < num3) {
            temp = num2;
            num2 = num3;
            num3 = temp;
        }

        System.out.print("Numbers in descending Order are : ");
        System.out.print(num1 + " " + num2 + " " + num3);
    }
}

Output
cse gtu, gtu study material for computer engineering students gujarattechnological university oop lab manual solution

gtu oop lab manual,

oop GTU Practical,

oop Programs,

Object oriented Programming,

Gtu study material 3140705,

OOP 3140705,

oop practical list,

Java Programming,

gtu oop practical,

oop lab solution gtu

Comments

YouTube

Popular posts from this blog

GTU OOP Program - 21

GTU OS Program - 3

GTU OOP Program - 1