Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Q 5,7
- public class MyClass {
- public static void main(String[] args) {
- int a = 5, b = 1 , c = 10;
- int max_two,max_three;
- //checking for two
- if (a>b)
- max_two = a;
- else
- max_two = b;
- // checking for three
- if(a>b){
- if(a>c){
- max_three = a;
- }
- else
- max_three = c;
- }
- else
- max_three = b;
- System.out.println("Greatest of two number is "+max_two);
- System.out.println("Greatest of three number is "+max_three);
- }
- }
- /*
- Greatest of two number is 5
- Greatest of three number is 10
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement