MHB Calculate Grades with iGrade Calculator

  • Thread starter Thread starter lypena35
  • Start date Start date
  • Tags Tags
    Calculator Grades
AI Thread Summary
The discussion revolves around creating a grade calculator program that allows students to input grades for lectures and labs, calculate averages, and determine letter grades based on specified percentages. The user successfully set up a menu for selecting between lab and lecture grades and established input prompts for grades and maximum points. Key challenges included calculating weighted averages based on different grading categories, such as exams, quizzes, homework, and participation. The program uses constants to represent weightings for each category, but the user initially struggled with the implementation of these calculations. Ultimately, the user resolved their issues and confirmed that they figured out the necessary calculations.
lypena35
Messages
18
Reaction score
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.
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:
Technology news on Phys.org
Never mind I figured it out thank you!
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top