0% found this document useful (0 votes)
7 views2 pages

Lab 1 Wed

The document outlines a Java program that calculates the average grade for three courses based on specific weightings for midterm and final grades. It determines if the overall average is above or below 60 to print either 'Passed the Class' or 'Failed.' The program prompts the user for input and calculates the averages accordingly.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Lab 1 Wed

The document outlines a Java program that calculates the average grade for three courses based on specific weightings for midterm and final grades. It determines if the overall average is above or below 60 to print either 'Passed the Class' or 'Failed.' The program prompts the user for input and calculates the averages accordingly.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

AOC Lab1 Wednesday

Question: Write a program that calculates the average grade for three courses by taking the
midterm and final grades for each course. The average for each course should be calculated
based on different weightings as follows:

1. Each course's average is calculated using these weightings:


o Course 1: Midterm 30%, Final 70%
o Course 2: Midterm 40%, Final 60%
o Course 3: Midterm 50%, Final 50%
2. If the total average of all three courses is above 60, print "Passed the Class."
3. If the total average of all three courses is below 60, print "Failed."

import java.util.Scanner;

public class CourseGradeCalculator {


public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

// Variables to store total averages


double totalAverage = 0;

// Course 1: Midterm 30%, Final 70%


System.out.println("Enter grades for Course 1:");
System.out.print("Midterm (30%): ");
double midterm1 = scanner.nextDouble();
System.out.print("Final (70%): ");
double final1 = scanner.nextDouble();
double average1 = (midterm1 * 0.3) + (final1 * 0.7);
System.out.println("Course 1 Average: " + average1);
totalAverage += average1;

// Course 2: Midterm 40%, Final 60%


System.out.println("\nEnter grades for Course 2:");
System.out.print("Midterm (40%): ");
double midterm2 = scanner.nextDouble();
System.out.print("Final (60%): ");
double final2 = scanner.nextDouble();
double average2 = (midterm2 * 0.4) + (final2 * 0.6);
System.out.println("Course 2 Average: " + average2);
totalAverage += average2;

// Course 3: Midterm 50%, Final 50%


System.out.println("\nEnter grades for Course 3:");
System.out.print("Midterm (50%): ");
double midterm3 = scanner.nextDouble();
System.out.print("Final (50%): ");
double final3 = scanner.nextDouble();
double average3 = (midterm3 * 0.5) + (final3 * 0.5);
System.out.println("Course 3 Average: " + average3);
totalAverage += average3;

// Calculate total average


totalAverage /= 3;
System.out.println("\nTotal Average: " + totalAverage);
// Determine pass or fail
if (totalAverage >= 60) {
System.out.println("Passed the Class.");
} else {
System.out.println("Failed.");
}

scanner.close();
}
}

You might also like