Last active
December 24, 2015 16:39
-
-
Save imryan/6829634 to your computer and use it in GitHub Desktop.
Calculates lab grades in a weird way. For CS 2.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class LabGrade | |
{ | |
public static void main (String[] args) | |
{ | |
// Declare constants | |
double inWeight = 0.6; // in-class weight is 60% | |
double outWeight = 0.4; // out-of-class weight is 40% | |
// Declare variables | |
double preLabPts; //number of points earned on the pre-lab assignment | |
double preLabMax; //maximum number of points possible for pre-lab | |
double labPts; //number of poitns earned on the lab | |
double labMax; //maximum number of points possible for lab | |
double postLabPts; //number of points earned on the post-lab assignment | |
double postLabMax; //maximum number of points possible for the post-lab | |
double outClassAvg; //average on the out of class (pre and post) work | |
double inClassAvg; //average on the in-class work | |
double labGrade; //final lab grade | |
Scanner scan = new Scanner(System.in); | |
// Get the input | |
System.out.println("\nWelcome to the Lab Grade Calculator\n"); | |
System.out.println("What is the weight of your in-class work?(in decimal format"); | |
inWeight = scan.nextDouble(); | |
System.out.print("Enter the number of points you earned on the pre-lab: "); | |
preLabPts = scan.nextDouble(); | |
System.out.print("\nWhat was the maximum number of points you could have earned? "); | |
preLabMax = scan.nextDouble(); | |
System.out.print("\nEnter the number of points you earned on the lab: "); | |
labPts = scan.nextDouble(); | |
System.out.print("\nWhat was the maximum number of points for the lab? "); | |
labMax = scan.nextDouble(); | |
System.out.print("\nEnter the number of points you earned on the post-lab: "); | |
postLabPts = scan.nextDouble(); | |
System.out.print("\nWhat was the maximum number of points for the post-lab? "); | |
postLabMax = scan.nextDouble(); | |
// Calculate the average for the out of class work | |
outClassAvg = (((preLabPts / preLabMax) * 100)+ ((postLabPts / postLabMax) * 100)) / 2; | |
// Calculate the average for the in-class work | |
inClassAvg = (labPts / labMax) * 100; | |
//Calculate the weighted average taking 40% of the out-of-class average | |
//plus 60% of the in-class | |
outWeight = 1 - inWeight; | |
labGrade = outWeight * outClassAvg + inWeight * inClassAvg; | |
//Print the results | |
System.out.println("\n\nYour average on out-of-class work is " + (Math.round(outClassAvg)) + "%"); | |
System.out.println("Your average on in-class work is " + (Math.round(inClassAvg)) + "%"); | |
System.out.println("Your lab grade is " + (Math.round(labGrade)) + "%"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment