Professional Documents
Culture Documents
Masten Project3
Masten Project3
Masten Project3
* Matt Masten
* CS1180, Summer 2018
* Project 3
*/
package masten_project3;
import java.util.Scanner;
/**
* Project 3
* This program will allow the user to enter in grades for Labs, Projects, Quiz
* and Exams. It will then average each section and find an overall average using
* a weighted value for each section
*/
public class WeightedGradeCalculator
{
//known constants
final double LAB_WEIGHT = .15;
final double PROJECT_WEIGHT = .25;
final double QUIZ_WEIGHT = .1;
final double EXAM_WEIGHT = .5;
//unknown values
double dblLabAverage;
double dblProjectAverage;
double dblQuizAverage;
double dblExamAverage;
double dblWeightedAverage;
double dblArraySum;
String strStudentName;
//test variable
char chNew;
chNew = 'Y';
/** Step 2 - get user's name and grades, Use input validation detailed
below
* lab grades between 0 and 10, Project grades between 0 and 50,
* quizzes between 0 and 20, and exams between 0 and 100. Each grade type
* going into the appropriate array.
*/
System.out.print("Enter the student's name: ");
strStudentName = keyboard.nextLine();
/** Step 4 - Calculate the weighted average from the weights and 4
* categories (Lab, Project, Quiz, Exam)
*/
//Lab Grades
System.out.println("Lab Grades for " + strStudentName+":");
for(int i = 0; i < arrLabGrades.length; i++)
{
System.out.printf("\tLab %d: %.1f\n", (i+1),arrLabGrades[i]);
}
System.out.printf("Lab average: %.2f%c\n\n", dblLabAverage,'%');
//Project Grades
System.out.println("Lab Grades for " + strStudentName+":");
for(int i = 0; i < arrProjectGrades.length; i++)
{
System.out.printf("\tProject %d: %.1f\n",
(i+1),arrProjectGrades[i]);
}
System.out.printf("Project average: %.2f%c\n\n",
dblProjectAverage,'%');
//Quiz Grades
System.out.println("Quiz Grades for " + strStudentName+":");
for(int i = 0; i < arrQuizGrades.length; i++)
{
System.out.printf("\tQuiz %d: %.1f\n", (i+1),arrQuizGrades[i]);
}
System.out.printf("Quiz average: %.2f%c\n\n", dblQuizAverage,'%');
//Exam Grades
System.out.println("Exam Grades for " + strStudentName+":");
for(int i = 0; i < arrExamGrades.length; i++)
{
System.out.printf("\tExam %d: %.1f\n", (i+1),arrExamGrades[i]);
}
System.out.printf("Exam average: %.2f%c\n\n", dblExamAverage,'%');
/** Step 5 Repeat steps 2 through 4 for additional students until user
* indicates they are finished.
*/
System.out.print("Do you wante to enter grades for another student
(Y/N)?");
chNew = keyboard.next().charAt(0);
keyboard.nextLine();
System.out.println("\n");
}