Saturday, 31 October 2015

Greatest of three numbers

import java.util.Scanner;
class Maximum
{
void printMaximum(int a,int b,int c)
{
int max=a;
if(b>max)
max=b;
if(c>max)
max=c;
System.out.printf("maximum is %d",max);
}
}
class MaximumTest
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
Maximum m1=new Maximum();
m1.printMaximum(a,b,c);
}
}

No comments:

Post a Comment