Posted by Somesh Shinde
On
Tuesday, 28 June 2016
Biggest of 3 Numbers using Logical Operators
Program
|
Output
|
//Note: Scanner class work with JDK1.5 or above import java.util.*; class Biggest3 { public static void main(String args[]) { int n1, n2, n3, big; Scanner scan= new Scanner(System.in); System.out.println("Please Enter No 1: "); n1=scan.nextInt(); System.out.println("Please Enter No 2: "); n2=scan.nextInt(); System.out.println("Please Enter No 3: "); n3=scan.nextInt(); if(n1>n2 && n1>n3) big=n1; else if(n2>n1 && n2>n3) big=n2; else big=n3; System.out.println("Biggest No: " + big); } }
|
Please Enter No 1: 5 Please Enter No 2: 23 Please Enter No 3: 14 Biggest No: 23
|
0 comments:
Post a Comment