1. Engineering
  2. Computer Science
  3. language is python software sequential processing goal compute student gpas...

Question: language is python software sequential processing goal compute student gpas...

Question details

Language is python software.

Sequential Processing

  • Goal:   Compute student GPAs from student records.
  • Input:   First and last name of desired student; student records for all students, redirected from grade-records.txt. Enter desired first and last name at the keyboard.
  • Output: GPA of desired student.
  • Relevant Example:   See the Employee Example in the Sequential Processing Section.  
  • Pseudocode:
    read desired_first_name from keyboard, prompting user
    read desired_last_name from keyboard, prompting user
    initialize total_credit_hours to 0
    initialize total_grade_points to 0.0
    open input file to create file object fin
    read and throw away first line
    read first line of input file
    while line not empty
        use split function to extract fields from line
        assign fields[1] to last_name 
        assign fields[2] to first_name
        assign fields[6] to credit_hours, converting to int
        assign fields[7] to grade
        if first_name is equal to desired_first_name and
           last_name is equal to desired_last_name
           
            if grade is equal to A
                assign credit_hours * 4 to grade_points
            else if grade is equal to B
                assign credit_hours * 3 to grade_points
            else if grade is equal to C
                assign credit_hours * 2 to grade_points               
            else if grade is equal to D
               assign credit_hours * 1 to grade_points               
            else
               assign credit_hours to zero
            end if..else statements    
        end if statement          
        update total_credit_hours
        update total_grade_points
    end while loop      
    close input file
    compute gpa = total_grade_points / total_credit_hours
    print(f"GPA for {first_name} {last_name} is {round(gpa, 2)}.")   
Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution