- #1
lypena35
- 18
- 0
Hello,
I have a question. I have to create a calculator for grades. I need to make a menu and the student picks either the lab or the lecture which I didn't have a problem with. I also didn't have a problem with the set up of the questions or the average calculations. What I am stuck on is: I was given percentages for the lecture: 50% of exams, 35% of quizzes and homework, and 15% class participation, and lab has 90% lab assignments and 10% lab participation. I have to ask the person to input the number of grades they have, for example 4 grades for exams 2 grades for quizzes and homework etc, then they input the maximum grade of all the categories (which are in points like 600 for example or in 0's and 1's for lab participation) and then they input the actual grades for each category. Then I have to calculate the average for the lab and lecture along with the alphabetical grade which is A100-90, B89-80 etc to 0%. How do I go about calculating all of that in my program? I tried different ways but I have so many numbers I don't know what is the right way of calculating it without it printing it out until the end. My program is below. Also if the problem is in the variables please let me know. Thank you.
I have a question. I have to create a calculator for grades. I need to make a menu and the student picks either the lab or the lecture which I didn't have a problem with. I also didn't have a problem with the set up of the questions or the average calculations. What I am stuck on is: I was given percentages for the lecture: 50% of exams, 35% of quizzes and homework, and 15% class participation, and lab has 90% lab assignments and 10% lab participation. I have to ask the person to input the number of grades they have, for example 4 grades for exams 2 grades for quizzes and homework etc, then they input the maximum grade of all the categories (which are in points like 600 for example or in 0's and 1's for lab participation) and then they input the actual grades for each category. Then I have to calculate the average for the lab and lecture along with the alphabetical grade which is A100-90, B89-80 etc to 0%. How do I go about calculating all of that in my program? I tried different ways but I have so many numbers I don't know what is the right way of calculating it without it printing it out until the end. My program is below. Also if the problem is in the variables please let me know. Thank you.
Code:
import java.util.Scanner;
public class iGrade {
public static void main(String[] args){
//initializing variables
int menu=0;
int lectureGrades=0;//equals option 1
int labGrade=0;//equals option 2
int exit;// equals option 3
int maxGrade;
int coursePercentage;
final double EXAM_WEIGHT=50.0;
final double QUIZ_AND_HOMEWORK_WEIGHT=35.0;
final double CLASS_PARTICIPATION_WEIGHT=15.0;
final double LAB_ASSIGNMENTS_WEIGHT=90.0;
final double LAB_PARTICIPATION_WEIGHT=10.0;
double examScore=0.0;
double quizHomeworkScore=0.0;
double classroomParticipationScore=0.0;
double labAssignments=0.0;
double labParticipation=0.0;
double sumOfNumbers=0.0;
double average;
Scanner input = new Scanner(System.in);
//menu
while(menu<=2){
System.out.println("1. Calculate 1301 Grades");
System.out.println("2. Calculate 1101 Grades");
System.out.println("3. Exit");
System.out.println("Welcome to iGrade, input the menu option you want (1, 2, or 3):");
menu=input.nextInt();
//Step 2 option 1 Calculate 1301 Grades
if(menu==1){
System.out.println("Please input the number of grades you have received for the lecture exams:");
menu=input.nextInt();
for(int e=0; e<menu;e++){//for loop for examScore
System.out.println("Input grade "+ (e+1));
examScore=input.nextInt();
}
//Step 3-5
//maximum grade for exams
System.out.println("Input the maximum grade of all the exams:");
EXAM_WEIGHT=input.nextInt();
// grades for quizzes and homework
System.out.println("Input the number of grades you have received for quizzes and homework assignments:");
quizHomeworkScore=input.nextInt();
for(int q=0; q<menu;q++){//for loop for input grade quizzes and homework
System.out.println("Input grade "+(q+1));
quizHomeworkScore=input.nextInt();
}
[B] quizHomeworkScore*100;
quizHomeworkScore/EXAM_WEIGHT;[/B] (this is the part I'm stuck on)
//maximum grade for quizzes and homeworks
System.out.println("Input the maximum grade for all the quiz and homework grades");
QUIZ_AND_HOMEWORK_WEIGHT=input.nextInt();
//grades for classroom participation
System.out.println("Input the number of grades you have received for classroom participation:");
classroomParticipationScore=input.nextInt();
for(int c=0; c<menu; c++){//for loop for input of classroom participation
System.out.println("Input grade " +(c+1));
classroomParticipationScore=input.nextInt();
}
//maximum grade for classroom participation
System.out.println("Input the maximum grade for all the classroom participation grades:");
CLASS_PARTICIPATION_WEIGHT=input.nextInt();
//Step 6 averages
for(int i=0; i<menu;i++){
System.out.println("Input grade "+ (i+1));
lectureGrades=input.nextInt();
sumOfNumbers+=lectureGrades;
}
//Average and letter grade calculation and output
average=(sumOfNumbers/menu);
System.out.printf("Your average is %.0f", average);
System.out.print(" which corresponds to a ");
//letter grade setup
if(lectureGrades<=100 && lectureGrades>=90){
System.out.print("A.");
}
else if(lectureGrades<=89 && lectureGrades>=80){
System.out.print("B.");
}
else if(lectureGrades<=79 && lectureGrades>=70){
System.out.print("C.");
}
else if(lectureGrades<=69 && lectureGrades>=60){
System.out.print("D.");
}
else if(lectureGrades<=59 && lectureGrades>=0){
System.out.print("F.");
}
System.out.println("");
}
else if(menu==3){
System.out.println("Good bye, thank you for using iGrade!");
break;
}
}
}
}
Last edited by a moderator: