Saturday 4 January 2014

skeleton code: real number comperation using Conditional Operator in Java ( ? : ) [ simple, user friendly ]


import java.util.Scanner;

class grps{
    public static void main(String[] args){
        Scanner input= new Scanner(System.in);
       
        System.out.print("enter the first input: ");
        double a=input.nextDouble();
       
        System.out.print("enter the nextinput: ");
        double b=input.nextDouble();
       
        System.out.println(a>b ? "First one is the bigger.":"Second one is the bigger."); //( ? : )
    }
}



No comments:

Post a Comment