Answer to Question #182749 in Python for Muhammad

Question #182749

Design a solution pseudocode that will receive student test result

record and print a student test grade report. The student test

record contains the student ID, name and test score (out of

50%). The program is to calculate the percentage of test score

and to print the student ID, name, test score over 50% and its

letter grade. The letter grade is determined as follows:

A=90-100%

B=80-89%

C=70-79%

D=60-69%

F=0-59%


1
Expert's answer
2021-04-19T19:12:26-0400
class grade_calculator:
   def __init__(self):
      self.__student_id = 0
      self._Name = ""
      self.__marks_obtained = []
      self.__total_marks = 0
      self.__percentage = 0
      self.__grade = ""
   def setgrade_calculator(self):
      self.__student_id = int(input("Enter student ID: "))
      self.__Name = input("Enter Name: ")
      print("Enter 5 subjects marks: ")
      for n in range(5):
         self.__marks_obtained.append(int(input("Subject " + str(n + 1) + ": ")))
   def Total(self):
      for i in self.__marks_obtained:
         self.__total_marks += i
   def Percentage(self):
      self.__percentage = self.__total_marks / 5
   def calculateGrade(self):
      if self.__percentage >= 90:
         self.__grade = "A"
      elif self.__percentage >= 80:
         self.__grade = "B"
      elif self.__percentage >= 70:
         self.__grade = "C"
      elif self.__percentage >= 60:
         self.__grade = "D"
      elif self.__percentage >= 0:
         self.__grade = "F"
         


   def showgrade_calculator(self):
      self.Total()
      self.Percentage()
      self.calculateGrade()
      print(self.__student_id, "\t", self.__Name, "\t", self.__total_marks, "\t", self.__percentage, "\t", self.__grade)
def main():
   gc = grade_calculator()
   gc.setgrade_calculator()
   gc.showgrade_calculator()
if __name__ == "__main__":
   main()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS