/* This is a basic program that uses a for loop
	It asks the user for a series of grade
	Then it calculates the average of the grade
	Hence, it determines the letter grade and print it out
	
*
*/

import java.util.Scanner;

public class Forloop
{
	public static void main(String[] args)
	{
		Scanner key = new Scanner(System.in);
		
		double grade;
		int num;
		double sum = 0.0, ave = 0.0;
		
		// Here will deteremine how many times we will loop
		
		System.out.print("How many grades are you planning to input\n");
		num = key.nextInt();
		
		/* Creates a for loop with "num" of times, starting at 0
			The loop will exit once i is greater than or equal to num
		*
		*/
		
		for (int i=0; i<num; i++)
		{
			// Asks the user for their grade
			
			System.out.print("Enter your first grade: \n");
			grade = key.nextDouble();
			
			sum +=grade; // Calculates the sum of the grade
		}
		
		ave = sum / num; // Cacluate the average 
		
		// We use a else-if statement to determine the letter grade
		
		if(ave>=90)
		{
			System.out.print("You recieve an A\n");
		}
		else if(ave>=80)
		{
			System.out.print("You recieve a B\n");
		}
		else if(ave>=70)
		{
			System.out.print("You recieve a C\n");
		}
		else if(ave>=60)
		{
			System.out.print("You recieve a D\n");
		}
		else
		{
			System.out.print("You recieve a F\n");
		}
	}
}