Monday, December 24, 2012

Find the biggest number java code

Find the biggest number java code

Today we will see, how to compare three number in java and finding the biggest number.
we will use if.. else if.. loop here!
Let’s see the code!

find the biggest number in java
find the biggest number java code ( Click to see big )
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication59;
import java.util.Scanner;
/**
*
* @author Rubel Orion
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// we will compare 3 number here and will find out
// the biggest number
Scanner s= new Scanner(System.in);
System.out.println(“Take R(number 1): “);
int R=s.nextInt();
System.out.println(“Take G(number 2): “);
int G=s.nextInt();
System.out.println(“take B(number 3): “);
int B=s.nextInt();
if(R<=G)
System.out.println(“Smallest Number is: “+R);
else if(R<=B)
System.out.println(“Smallest number is: ” +R);
else if(G<=B)
System.out.println(“Smallest number is: “+G);
System.out.println(“Powered By: www.asifur95.blogspot.com”);
}
}

No comments:

Search your topic!

Flag Counter