A simple letter grades program in Java programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.Please subscribe to my channel  https://www.youtube.com/channel/UCOs-lpOoIeJoh6gpJthPoGgThank you very much for your support.

Program Listing

/* grades.java
 *
 * Author : Jake Rodriguez Pomperada, MAED-IT, MIT
 * www.jakerpomperada.com  and www.jakerpomperada.blogspot.com
 * jakerpomperada@gmail.com
 * Bacolod City, Negros Occidental Philipipines
 */

import java.util.Scanner;

public class letter_grades
{
  private static int sumOfArray(int [] arr)
  {
   int sum = 0;
  
   for (int i : arr)
       sum += i;
  
   return sum;          
  }
  private static char getGrade(int grade)
  {
     
     if (grade >= 91 && grade <= 100)
        return 'A';
     else if (grade >= 81 && grade <= 90)
        return 'B';
     else if (grade >= 71 && grade <= 80)
        return 'C';
     else if (grade >= 61 && grade <= 70)
        return 'D';
     else if (grade <= 60)
        return 'E';  
              
     return 0;
  }
  public static void main(String[] args) 
  {
    System.out.println("\n\tLetter Grades in Java\n");
    System.out.print("# of grades: ");
    
    Scanner input = new Scanner(System.in);
    int numberOfGrades = input.nextInt();
    int[] scores = new int[numberOfGrades]; 
    
    for (int i = 0; i < scores.length; i++) 
    {
      System.out.printf("Grade (%d): ", i + 1);
      scores[i] = input.nextInt();        
    }
    int total_sum = sumOfArray(scores);
    int avg = (total_sum / numberOfGrades) * 10;
       
    String output = "";
    output += "Your Grade is " + avg + ": Descriptive Rating: " + getGrade(avg);
       
    System.out.println(output);
    input.close();
  }
}

Leave a Reply

Your email address will not be published.