Sunday 26 July 2009

This programme finds out the Sum, Average, Maximum and Minimum of any Given Number

import java.util.Scanner;
public class suminmaxav{
public static void main( String args[] ){
Scanner input = new Scanner( System.in );
double c,n,max,min,sum;
int z;
System.out.print( "How much Number you want to enter? : " );
z= input.nextInt();
System.out.print( "Enter Number: " );
n = input.nextDouble();
max=n;
min=n;
sum=n;
c=1;
while(c System.out.print( "Enter Number: " );
n = input.nextDouble();
if (n>max){
max=n;}
else if (n min=n;}
c=c+1;
sum=sum+n;
}
System.out.println("The sum is :" + sum);
System.out.println("The average is :" + sum/z);
System.out.println("The Minimum Number is :" + min);
System.out.println("The Maximum Number is :" + max);
}
}

No comments:

Post a Comment