Pseudo Code Generator

Grade Calculation Pseudo Code

A structured pseudo code outlining a grading system that inputs assessment details, collects student grades, calculates individual scores, and determines class averages and top students.


Empty image or helper icon

Prompt

def calculateGrade(per):
    if per >= 85:
        grade = 'High Distinction'
    elif per>= 75:
        grade = 'Distinction'
    elif per >= 65:
        grade = 'Credit'
    elif per >= 50:
        grade = 'Pass'
    else:
        grade = 'Fail'
    return grade
numAssessments = int (input("Enter the number of assessements:"))
assessmentNames = []
assessmentValues = []

var = 0
while var < numAssessments:
    nam = input ("The name of assessment{}:".format(var+1))
    val = float (input("How many marks is the {} worth:".format(nam)))
    assessmentNames.append(nam)
    assessmentValues.append(val)
    var +=1
    
if sum(assessmentValues) != 100:
    print("Assessment VALUE ERROR: try to give different input: ")
    exit()
    
numStudent = int (input("Kindly enter the no.of students: "))

total_class = 0
topperNAME = ""
topper_student = 0

for j in range(numStudent):
    name_of_student = input("Enter name: ")

    total_no_student = 0
   
    var = 0
    while var < (numAssessments):
        maximumMarks = assessmentValues[var]
        assessmentName = assessmentNames[var]

        total_mark = int(input("What did {} get out of {} in the {}?".format(name_of_student, maximumMarks, assessmentNames[var])))
        var += 1
        if total_mark < 0:
            total_mark = 0
        elif total_mark > maximumMarks:
            total_mark = maximumMarks
        total_no_student = total_no_student + total_mark
        
        per = (total_mark/maximumMarks) * 100
        score = calculateGrade(per)
        
        print ("{} out of {} is a {}.".format (total_mark, maximumMarks, score)) 
    
    final_score_student = calculateGrade((total_no_student / 100) * 100)
    print ("{} has total mark of {} , {}".format (name_of_student, total_no_student, final_score_student))
    print ("All marks entered!")

    
    total_class = total_class+total_no_student

    if total_no_student > topper_student:
        topper_student = total_no_student
        topperNAME = name_of_student

Average = total_class / numStudent
C_average = calculateGrade(Average)
print("Average is {:.0f} ({}).".format (Average, C_average))
print("Top student is {} with score of {}.".format(topperNAME, topper_student))

Answer

Pseudo Code for Grade Calculation Program

Overview

This pseudo code represents the logic for a grading system that:

  1. Takes assessment details from users.
  2. Collects student grades for each assessment.
  3. Calculates individual grades and class averages.

Functions

Calculate Grade Function

FUNCTION calculateGrade(percentage):
    IF percentage >= 85:
        grade = 'High Distinction'
    ELSE IF percentage >= 75:
        grade = 'Distinction'
    ELSE IF percentage >= 65:
        grade = 'Credit'
    ELSE IF percentage >= 50:
        grade = 'Pass'
    ELSE:
        grade = 'Fail'
    RETURN grade

Main Program Logic

BEGIN MAIN

    // Input number of assessments
    numAssessments = GET INTEGER INPUT("Enter the number of assessments:")

    // Initialize lists for assessment names and values
    assessmentNames = []
    assessmentValues = []

    // Loop to collect assessment names and their respective marks
    FOR var FROM 0 TO numAssessments - 1:
        nam = GET STRING INPUT("The name of assessment" + (var + 1))
        val = GET FLOAT INPUT("How many marks is the " + nam + " worth:")
        ADD nam TO assessmentNames
        ADD val TO assessmentValues
    
    // Validate total marks of assessments
    IF SUM(assessmentValues) != 100:
        PRINT "Assessment VALUE ERROR: try to give different input:"
        EXIT

    // Input number of students
    numStudent = GET INTEGER INPUT("Kindly enter the number of students:")

    // Initialize variables for class average and top student
    total_class = 0
    topperNAME = ""
    topper_student = 0

    // Loop to collect individual student scores
    FOR j FROM 0 TO numStudent - 1:
        name_of_student = GET STRING INPUT("Enter name:")

        total_no_student = 0
        
        // Loop to collect each student's marks for all assessments
        FOR var FROM 0 TO numAssessments - 1:
            maximumMarks = assessmentValues[var]
            assessmentName = assessmentNames[var]

            total_mark = GET INTEGER INPUT("What did " + name_of_student + " get out of " + maximumMarks + " in the " + assessmentNames[var] + "?")
            
            // Ensure total_mark is within bounds
            IF total_mark < 0:
                total_mark = 0
            ELSE IF total_mark > maximumMarks:
                total_mark = maximumMarks
                
            total_no_student = total_no_student + total_mark
            
            // Calculate percentage and grade for current assessment
            per = (total_mark / maximumMarks) * 100
            score = calculateGrade(per)
            
            PRINT total_mark + " out of " + maximumMarks + " is a " + score + "."

        // Calculate final score for the student
        final_score_student = calculateGrade((total_no_student / 100) * 100)
        PRINT name_of_student + " has total mark of " + total_no_student + " , " + final_score_student
        PRINT "All marks entered!"

        total_class = total_class + total_no_student

        // Identify topper student
        IF total_no_student > topper_student:
            topper_student = total_no_student
            topperNAME = name_of_student

    // Calculate class average and corresponding grade
    Average = total_class / numStudent
    C_average = calculateGrade(Average)
    
    PRINT "Average is " + FORMAT(Average, 0) + " (" + C_average + ")."
    PRINT "Top student is " + topperNAME + " with score of " + topper_student + "."
    
END MAIN

Conclusion

This pseudo code clearly outlines the steps involved in calculating grades for assessments and students, ensuring clarity and simplicity for understanding the program's logic and structure.

Create your Thread using our flexible tools, share it with friends and colleagues.

Your current query will become the main foundation for the thread, which you can expand with other tools presented on our platform. We will help you choose tools so that your thread is structured and logically built.

Description

A structured pseudo code outlining a grading system that inputs assessment details, collects student grades, calculates individual scores, and determines class averages and top students.