Hello,
I am a newbie to Java and I am having troubles with my code. It does not calculate the maximum, minimum or average of the 10 numbers that the user is prompted to input. So I turn to the ones who know Java and programming, you. I know this may seem like a stupid question, but I hope you can give me some insight to where my problem lies. Thank you, any help is deeply appreciated.
My code:
import java.util.Scanner;
public class moretest
{
public static void main( String [ ] args )
{
int total = 0;
int number;
int minGrade = 101;
int maxGrade = 0;
float average;
Scanner scan = new Scanner( System.in);
for ( int i = 0; i < 1; i++ ) //Executes 1 time
{
System.out.println("Enter ten scores between 0 and a 100");
for ( int n = 0; n < 10; n++ ) //Executes 10
{
System.out.println("Score: ");
number = scan.nextInt ( );
if (number > maxGrade)
{
maxGrade = number;
}
if ( number < minGrade )
{
minGrade = number;
}
if (number > -1 && number < 101)
{
total = total + number;
}
else{
System.out.println("Input values are not acceptable, try again."); //The message displayed when number is out of range
}
average = total/10; //to calculate the average
}
}
}
}
--- I hope I posted under the right sub-post..