5-4 MaxMin
Post date: Apr 3, 2014 10:26:26 AM
/*Write a program containing two functions that return values. The first Function returns
the higher of two numbers entered by the user. The second Function returns the lowest
number. The parameters for the two functions are entered through the main function.*/
package maxmin;
import java.util.Scanner;
public class MaxMin
{
public static void main(String[] args)
{
Scanner Scan=new Scanner(System.in);
System.out.print("Enter the number1 : ");
double n1=Scan.nextDouble();
System.out.print("Enter the number2 : ");
double n2=Scan.nextDouble();
System.out.println("Max="+Max(n1,n2));
System.out.println("Min="+Min(n1,n2));
}
public static double Max(double a,double b)
{
return(a>b)?a:b;
}
public static double Min(double a,double b)
{
return(b<a)?b:a;
}
}