Question: How can I make this code an infinite loop that prints out an output before each new loop starts import sys print ( Invoice

How can I make this code an infinite loop that prints out an output before each new loop starts
import sys
print("Invoice")
print("Columbus State University")
print("4225 University Ave.")
print("Columbus, GA 31907")
print("-"*30)
invalid_input = True
def get_student_info():
#Prompts the user for student details and validates input until valid data is provided.
invoice = input("Do you need to create an invoice (Y or N)?")
if invoice in ["N"]:
print("Have a good day!")
sys.exit()
while True:
name = input("Enter student name: ")
if name.strip():
break
print("Invalid name. Please enter a name.")
enter_Address = input("Enter your address:")
enter_Location= input("Enter your city, state, and zip code:")
print("-"*30)
print(name)
print(enter_Address)
print(enter_Location)
print("-"*30)
while True:
student_type = input("Are you a undergraduate or graduate (U or G): ").upper()
if student_type in ["U","G"]:
break
print("Invalid student type. Please enter 'U' or 'G'.")
while True:
try:
credit_hours = int(input("Enter credit hours: "))
if 1<= credit_hours <=25 if student_type =="Y" else 1<= credit_hours <=15:
break
print("Invalid credit hour range. Please enter between 1 and 25(Undergraduate) or 1 and 15(Graduate).")
except ValueError:
print("Invalid input. Please enter a number.")
while True:
tuition_status = input("Are you in-state(I),Out-of-State(O),or Out-of-Country(C):").upper()
if tuition_status in ["I","O","C"]:
break
print("Please enter 'I','O',or 'C'")
while True:
online_class = input("Are you taking any online classes(Y or N):")
if online_class in ["Y","N"]:
break
print("Invalid answer. Please enter 'Y' or 'N'.")
while True:
military_status = input("Are you in the military(Y or N):")
if military_status in ["Y","N"]:
break
print("Invalid answer. Please enter 'Y' or 'N'.")
return name, student_type, credit_hours, tuition_status
def calculate_tuition(credit_hours, tuition_status, student_type):
#Calculates tuition based on credit hours, tuition status, and student type.
if student_type =="U":
per_credit_cost ={"I": 187,"O": 675,"C": 688}
if credit_hours >15:
return 15* per_credit_cost[tuition_status]
else:
return credit_hours * per_credit_cost[tuition_status]
else:
per_credit_cost ={"I": 215,"O": 858,"C": 874}
if credit_hours >12:
return 12* per_credit_cost[tuition_status]
if online_class =='Y':
return (tuition_amount +395)
if military_status =='Y':
return 0* fixed_fees
else:
return credit_hours * per_credit_cost[tuition_status]
invalid_input_invoice = True
def print_invoice(name, student_type, credit_hours, tuition_status, tuition_amount, fixed_fees):
#Prints the invoice with calculated details.
print("-"*30)
print("Columbus State University Invoice")
print("Student Type:", student_type)
print("Credit Hours:", credit_hours)
print("Tuition Status:", tuition_status)
print("Tuition Amount:", tuition_amount)
print("Fixed Fees:", fixed_fees)
print("Total Amount:", tuition_amount + fixed_fees)
print("-"*30)
if __name__=="__main__":
fixed_fees =67+200+30+57+10+62+195+84 # Sum of all fixed fees
student_info = get_student_info()
name, student_type, credit_hours, tuition_status = student_info
tuition_amount = calculate_tuition(credit_hours, tuition_status, student_type)
print_invoice(name, student_type, credit_hours, tuition_status, tuition_amount, fixed_fees)
while invalid_input:
get_student_info()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!