Bit1

Asg(3)

May 30th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.25 KB | None | 0 0
  1. def filewrite(student_ID, studentName, a1_Weightedmark, a2_Weightedmark, fe_Weightedmark, total_Weightedmark, total):
  2.  
  3.     outfile = open ("students.txt", 'a')
  4.    
  5.     outfile.write("Student   Student             A1     A2    Final   Weighted  Weighted Total \n ID        Name                             Exam    Total     with Bonus \n --------------------------------------------------------------------------")
  6.    
  7.     outfile.write('\n' + str(student_ID))
  8.  
  9.     outfile.write(str(studentName.rjust(15)))
  10.  
  11.     outfile.write(format(a1_Weightedmark,'10.1f'))
  12.  
  13.     outfile.write(format(a2_Weightedmark,'10.1f'))
  14.  
  15.     outfile.write(format(fe_Weightedmark,'10.1f'))
  16.  
  17.     outfile.write(format(total_Weightedmark,'10.1f'))
  18.  
  19.     outfile.write(format(total,'10.1f'))
  20.  
  21.     outfile.write('\n')
  22.    
  23.    
  24. def main():
  25.    
  26.      loop = True
  27.      while loop:
  28.    
  29.        student_ID = int(input("Please enter the student ID:"))
  30.        studentName = (input ("Please enter the student name:"))                
  31.        a1_Mark = float(input ("Please enter the marks for Assignment 1:"))
  32.        a1_Weightedmark = a1_Mark * 20/100
  33.  
  34.        a2_Mark = float(input ("Please enter the marks for Assignment 2:"))
  35.        a2_Weightedmark = a2_Mark * 30/100
  36.  
  37.        fe_Mark = float(input ("Please enter the marks for the Final Exam:"))
  38.        fe_Weightedmark = fe_Mark * 50/100
  39.        
  40.        total_Aweightedmarks = a1_Weightedmark + a2_Weightedmark
  41.        total_Weightedmark = total_Aweightedmarks + fe_Weightedmark
  42.    
  43.    
  44.     #find the bonus points and add them on to total mark.
  45.        if total_Weightedmark >=50 and total_Weightedmark <=70:
  46.         bonusCalc = total_Weightedmark - 50
  47.         bonus_marks = bonusCalc *10/100
  48.         total = total_Weightedmark + bonus_marks
  49.        
  50.    
  51.        elif total_Weightedmark >=70 and total_Weightedmark <=90:
  52.         bonusCalc = total_Weightedmark - 70
  53.         bonus_marks = bonusCalc *15/100 + 2
  54.         total = total_Weightedmark + bonus_marks
  55.        
  56.  
  57.        elif total_Weightedmark >=90 and total_Weightedmark <=100:
  58.         bonusCalc = total_Weightedmark - 90
  59.         bonus_marks = bonusCalc *20/100 + 5
  60.         total = total_Weightedmark + bonus_marks
  61.        
  62.        
  63.        
  64.  
  65.        else:
  66.         bonus_marks = 0
  67.         total = total_Weightedmark
  68.        
  69.        if total >100:
  70.           total = 100
  71.        
  72.        
  73.        print ("Thank You!")
  74.  
  75.  
  76.        print ("Weighted mark for Assignment 1:")
  77.        print (a1_Weightedmark)
  78.  
  79.        print ("Weighted mark for Assessment 2:")
  80.        print (a2_Weightedmark)
  81.  
  82.        print ("Total weighted mark of the assignments:")
  83.        print (total_Aweightedmarks)
  84.  
  85.        print ("Weighted mark for the Final Exam is:")
  86.        print (fe_Weightedmark)
  87.  
  88.        print ("Total weighted mark for the subject:")
  89.        print (total_Weightedmark)
  90.  
  91.        print ("Bonus points:")
  92.        print (bonus_marks)
  93.  
  94.        print ("Total mark with bonus:")
  95.        print (total)
  96.        filewrite(student_ID, studentName, a1_Weightedmark, a2_Weightedmark, fe_Weightedmark, total_Weightedmark, total)
  97.        menuInput = str(input("Do you want to enter another student Y/N?"))
  98.        if menuInput == "Y":
  99.           loop = True
  100.        else:
  101.           loop = False
  102.          
  103. main()
Add Comment
Please, Sign In to add comment