GPA calculator:
Assume the user has a bunch of courses they took, and need to
calculate the overall GPA.
We will need to get the grade and number of units for each
course.
It is not ideal to ask how many courses they took, as they have to
manually count their courses. Programming is about automation and
not manual work.
We will create a textual menu that shows 3 choices.
1. Enter course grade and units.
2. Show GPA.
3. Quit.
The user is expected to enter 1, and then enter a course grade and its number of units. They can then choose 1 and enter another course grade and units, or choose 2, and the code displays their GPA based on all the courses entered so far. If the user enters 3, the system quits. After the user chooses options 1 or 2, the code executes that menu option then shows the menu again. When the user chooses menu option 3, we do not repeat the menu.
This requires us to write code that follows this logic:
It is common practice to place the main function code at the bottom and place the other functions above main. If you write more functions that call other functions, then the function that gets called is placed towards the top while the function that calls other functions is placed towards the bottom.
NOTE: DO NOT USE WHILE LOOP AND MAKE SURE THAT YOU FOLLOW THE INSTRUCTIONS CAREFULLY OR YOU WILL SURELY GET A THUMBS DOWN
Solution for above problem statement in Python
'''
Online Python Compiler.
Code, Compile, Run and Debug python program online.
Write your code in this editor and press "Run" button to execute
it.
'''
totalPoints = 0
totalUnits = 0
def display():
print("1. Enter course grade and units.")
print("2. Show GPA.")
print("3. Quit.")
choice = input()
if choice in ['1','2','3']:
return int(choice)
else:
print("Invalid input")
return -1
def legal(amount,lowerBound,upperBound):
if(amount>=lowerBound and amount<=upperBound):
return True
else:
return False
def main():
global totalPoints
global totalUnits
choice = display()
if choice == 1:
grade = int(input("Enter grade : "))
unit = int(input("Enter unit : "))
b1=legal(grade,0,4)
b2=legal(unit,1,5)
if(b1==True and b2==True):
totalPoints=totalPoints+(grade*unit)
totalUnits = totalUnits+unit
else:
print("Either grade or units is illegal.")
main()
if choice == 2:
currentGPA = totalPoints/totalUnits
print("Current GPA = "+str(currentGPA))
main()
if choice ==3:
return
if choice == -1:
main()
main()
Screenshot of the output:
GPA calculator: Assume the user has a bunch of courses they took, and need to calculate...
Python GPA calculator: Assume the user has a bunch of courses they took, and need to calculate the overall GPA. We will need to get the grade and number of units for each course. It is not ideal to ask how many courses they took, as they have to manually count their courses. Programming is about automation and not manual work. We will create a textual menu that shows 3 choices. 1. Input class grade and number of units. 2....
Has to be written in Python 3 GPA calculator: Assume the user has a bunch of courses they took, and need to calculate the overall GPA. We will need to get the grade and number of units for each course. It is not ideal to ask how many courses they took, as they have to manually count their courses. Programming is about automation and not manual work. We will use a while loop and after getting the data of one...
Write the following program in C++. Review structures, pointers and dynamic memory allocation from CSIT 839. Also, review pointers and dynamic memory allocation posted here under Pages. For sorting, you can refer to the textbook for Co Sci 839 or google "C++ sort functions". I've also included under files, a sample C++ source file named sort_binsearch.cpp which gives an example of both sorting and binary search. The Bubble sort is the simplest. For binary search too, you can refer to...
C++ programming For this assignment, write a program that will act as a geometry calculator. The program will be menu-driven and should continue to execute as long as the user wants to continue. Basic Program Logic The program should start by displaying a menu similar to the following: Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice(1-3): and get the user's choice as an integer. After the choice...
You will create a class to store information about a student�s courses and calculate their GPA. Your GPA is based on the class credits and your grade. Each letter grade is assigned a point value: A = 4 points B = 3 points C = 2 points D = 1 point An A in a 3 unit class is equivalent to 12 grade points (4 for the A times 3 unit class) A C in a 4 unit class is...
Problem Specification:Write a C++ program to calculate student’s GPA for the semester in your class. For each student,the program should accept a student’s name, ID number and the number of courses he/she istaking, then for each course the following data is needed the course number a string e.g. BU 101 course credits “an integer” grade received for the course “a character”.The program should display each student’s information and their courses information. It shouldalso display the GPA for the semester. The...
Create a GPA calculator in Java. Ask the end user for the credit hours and letter grade for each class. Once the user is finished with the data entry, calculate and output the overall GPA for the given input. For example, if four classes are input, each of which is a three-hour course, with grades of A, B, B, and B, the overall GPA will be 3.25. The exact user interaction is up to you. As long as the requirements...
Matlab a) Write a MATLAB code that takes the grade letters from the user and provide him/her with the GPA for that semester Enter your grades (letters): AABBC (input) Your GPA is 3.2 output) b) Write a Matlab user defined function to that takes a letter grade and return a numeric grade as shown in the table below. Any other value should give an error message (Invalid Grade). You function name should be Letter2Grade Use the following information to calculate...
This question was answered by someone else but their code doesn't work when I try to run it. Q1. Currently, you are enrolled in the Spring semester and taking five courses. Write a program that asks the user to enter the final score of each course. The program should display a letter grade for each class, a statement based on a letter grade, and a spring semester GPA. Each course has 3 credit hours. Write the following functions in the...