This is the code I have, I need to change it to a menu driven option:

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter9: Advanced Array Concepts
Section: Chapter Questions
Problem 10PE
icon
Related questions
Question

This is the code I have, I need to change it to a menu driven option:

print('Welcome to our hours of study calculator! Easily determine how many hours you have to study based on the grade you want! Thank you for using my program! Have a great day.')


#initalize variables

run_again = 'Y'

total_credits = 0
allstudents_studyhours = 0
total_students = 0

while run_again.upper() == 'Y':#Loop continues as long as user enters Y
    full_name = ""

    #str
    first_name = ""
    last_name = ""
    full_name = ""
    grade_wanted = ""
    credits_taken = ""

    #int
    
    number_of_classes = 0
    studyhours_needed = 0
    total_number_studyhours_perstudent= 0
    
     #list
    grades = ['A','B','C','D','F']

    first_name = input('Please enter your first name:')
#1-Ask user's first_name
    while first_name =="": #validate that the user entered a name.
        print('You must enter a valid name:')
        first_name = input('Please enter your first name:')
#1A-Ask user's last_name
    last_name = input('Please enter you last name:')  
    while last_name == "":#validate that the user entered a last name
        print('You must enter a valid last name:')
        last_name = input('Please enter you last name:') 
#2-Ask user how many credits they are taking
    credits_taken = input('Please enter number of credits youre taking:')    
    while not credits_taken.isdigit() or int(credits_taken) < 3 or int(credits_taken)> 18 or int(credits_taken) % 3:  #validation of credits each student is taking.
        print('Enter a valid number of credits you are taking, if each class is 3 credits:')
        credits_taken = input('Please enter number of credits youre taking:') 
     
#3-Ask user what grade they would like to receive(assume same for all classes.)
    grade_wanted = input('Please enter the grade wanted for your classes:')
    while not grade_wanted.upper() in grades:          #validating grades
        print( 'Please enter a valid grade:')
        grade_wanted = input('Please enter the grade wanted for your classes:')

    grade_wanted = grade_wanted.upper()
####Calculations
##4 We are calculating the total number of classes the student is taking
    number_of_classes = (int(credits_taken) / 3)

##5 Calculating the total number of hours student will have to study, per class, to acheive the grade wanted. Assume the same for each class.
    if grade_wanted == 'A':
        studyhours_needed = 15
    elif grade_wanted == 'B':
        studyhours_needed = 12
    elif grade_wanted == 'C':
        studyhours_needed = 9
    elif grade_wanted == 'D':
        studyhours_needed = 6
    else:
        grade_wanted == 'F'
        studyhours_needed = 0
       
##6 Calculating the total number of hours the student must study for all classes.
    total_number_studyhours_perstudent = (number_of_classes * studyhours_needed)

##7 We are going to display the following information to the user.    
    print('Name:',first_name + " "+ last_name)
    print('Credits:', credits_taken)
    print('Study Hours:',total_number_studyhours_perstudent)
    print('Grade:', grade_wanted)

##8 Calc the total number of students who used the program.
    total_students = total_students + 1

##9 Calc total number of credits taken by all students who used the program.
    total_credits = total_credits + int(credits_taken)
   # print(total_credits)
#10 Calc total number of study hours for all students who used the program.
    allstudents_studyhours = total_number_studyhours_perstudent + allstudents_studyhours
   # print(allstudents_studyhours)
#11 This will determine if you would like to keep running the program, or quit.
    run_again = input('Would you like to continue using the program? If yes, please enter Y, any other key will exit')

#12 Calculate and display the following information to the user.
print('Total Students:', total_students)
print('Average Credits:', total_credits / total_students)
print('Average Study Hours:', allstudents_studyhours / total_students)

⦁    The menu driven program has the following options:
⦁    Determine Hours to Study
⦁    Determine Grade 
⦁    Display Averages and Totals
⦁    Quit

 

please help me turn these into a menu

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Mouse Control
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning