Saturday 9 August 2014

Write a Program in java which use if else conditions to find greater number

Structure of the Problem Requirements 

In this problem we will learn how to use If Else condition and their scope in Java Programming . User will enter two numbers and with using IF ELSE condition the program will generate the output which is greater number between these two numbers. When 1st If condition fail then the program will enter in its else condition other just follow the If condition if it true then leave the Else condition. Here is the Source code which help you in better understanding .

Source Code 

package com.ancodingpoint.www;

import java.util.Scanner;


public class conditions
public static void main(String[] args)
{
            Scanner input = new Scanner (System.in);
            int a,b =0;
            System.out.println(" Enter Your Number ");
            a = input.nextInt();
            System.out.println(" Enter Your Number ");
            b = input.nextInt();
            if (a==b)
            {
            System.out.println(a + " is Equal :" + b );
            }
            else
                
            if (a>b)
            {
                System.out.println(a + " Greater Then :" + b );
            }
            else
            {
                System.out.println(b + " Greater Then :" + a );
            }
        }
}

Output of the Program

Java Programming
Greater Number



Share it Please
asad

About Author!

Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.

0 comments:

Post a Comment