Hello, I have been working on this code for a while now and I have encountered difficulties in getting it to function as intended. Can someone help me with this code and how to fix it? The code I currently have is: # Initialize the required CS credits earned earned_credit_hours = 0 # Print the header print("--------------------------------") print(" UIC CS Track") print("--------------------------------\n") # QUESTION 1: Are you a CS major? major_answer = input("QUESTION 1\nAre you a CS major? (Yes or No): ").upper() if major_answer == "YES": # QUESTION 2: Have you taken ENGR100? engr100_answer = input("\nQUESTION 2\nHave you taken ENGR100? (Yes or No): ").upper() # QUESTION 3: Have you taken CS111 and CS112? cs111_answer = input("\nQUESTION 3\nHave you taken CS111? (Yes or No): ").upper() # Check if CS111 is taken if cs111_answer == "YES": earned_credit_hours += 3 print("\nQUESTION 4") cs141_answer = input("Have you taken CS141? (Yes or No): ").upper() if cs141_answer == "YES": earned_credit_hours += 3 print("\nQUESTION 5") cs151_answer = input("Have you taken CS151? (Yes or No): ").upper() if cs151_answer == "YES": earned_credit_hours += 3 print("\nQUESTION 6") cs211_answer = input("Have you taken CS211? (Yes or No): ").upper() if cs211_answer == "YES": earned_credit_hours += 3 print("\nQUESTION 7") cs251_answer = input("Have you taken CS251? (Yes or No): ").upper() if cs251_answer == "YES": earned_credit_hours += 4 print("Have you taken CS277? (Yes or No): ", end='') cs277_answer = input().strip().upper() if cs277_answer == "YES": earned_credit_hours += 3 print("Have you taken CS377? (Yes or No): ", end='') cs377_answer = input().strip().upper() if cs377_answer == "YES": earned_credit_hours += 3 print("Have you taken CS401? (Yes or No): ", end='') cs401_answer = input().strip().upper() if cs401_answer == "YES": earned_credit_hours += 3 print("\nQUESTION 8") cs261_answer = input("Have you taken CS261? (Yes or No): ").upper() if cs261_answer == "YES": earned_credit_hours += 4 # Print the summary for CS majors print("\n--------------------------------") print(" Summary") print("--------------------------------\n") print("You are a CS major!") if engr100_answer == "NO": print("Do not forget to take ENGR100!") print("\nRequired CS credits earned:", earned_credit_hours, end=".\n") else: # Print the summary for non-CS majors print("\n--------------------------------") print(" Summary") print("--------------------------------\n") print("Sadly, you are not a CS major.") # Goodbye message print("\nThank you for using App!") print("Closing app...")

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Hello, I have been working on this code for a while now and I have encountered difficulties in getting it to function as intended. Can someone help me with this code and how to fix it? 

The code I currently have is:

# Initialize the required CS credits earned
earned_credit_hours = 0

# Print the header
print("--------------------------------")
print("         UIC CS Track")
print("--------------------------------\n")

# QUESTION 1: Are you a CS major?
major_answer = input("QUESTION 1\nAre you a CS major? (Yes or No): ").upper()

if major_answer == "YES":
    # QUESTION 2: Have you taken ENGR100?
    engr100_answer = input("\nQUESTION 2\nHave you taken ENGR100? (Yes or No): ").upper()

    # QUESTION 3: Have you taken CS111 and CS112?
    cs111_answer = input("\nQUESTION 3\nHave you taken CS111? (Yes or No): ").upper()

    # Check if CS111 is taken
    if cs111_answer == "YES":
        earned_credit_hours += 3

        print("\nQUESTION 4")
        cs141_answer = input("Have you taken CS141? (Yes or No): ").upper()
        if cs141_answer == "YES":
            earned_credit_hours += 3
            
            print("\nQUESTION 5")
            cs151_answer = input("Have you taken CS151? (Yes or No): ").upper()
            if cs151_answer == "YES":
                earned_credit_hours += 3
                
                print("\nQUESTION 6")
                cs211_answer = input("Have you taken CS211? (Yes or No): ").upper()
                if cs211_answer == "YES":
                    earned_credit_hours += 3

                print("\nQUESTION 7")
                cs251_answer = input("Have you taken CS251? (Yes or No): ").upper()
                if cs251_answer == "YES":
                    earned_credit_hours += 4
                    
                    print("Have you taken CS277? (Yes or No): ", end='')
                    cs277_answer = input().strip().upper()
                    if cs277_answer == "YES":
                        earned_credit_hours += 3
                        
                    print("Have you taken CS377? (Yes or No): ", end='')
                    cs377_answer = input().strip().upper()
                    if cs377_answer == "YES":
                        earned_credit_hours += 3

                    print("Have you taken CS401? (Yes or No): ", end='')
                    cs401_answer = input().strip().upper()
                    if cs401_answer == "YES":
                       earned_credit_hours += 3
                print("\nQUESTION 8")
                cs261_answer = input("Have you taken CS261? (Yes or No): ").upper()
                if cs261_answer == "YES":
                    earned_credit_hours += 4

    # Print the summary for CS majors
    print("\n--------------------------------")
    print("           Summary")
    print("--------------------------------\n")

    print("You are a CS major!")
    if engr100_answer == "NO":
        print("Do not forget to take ENGR100!")

    print("\nRequired CS credits earned:", earned_credit_hours, end=".\n")

else:
    # Print the summary for non-CS majors
    print("\n--------------------------------")
    print("           Summary")
    print("--------------------------------\n")

    print("Sadly, you are not a CS major.")

# Goodbye message
print("\nThank you for using App!")
print("Closing app...")
Traceback (most recent call last):
File "/usercode/main.py", line 58, in module>
ca261 answer
EOFError: EOF when reading a line
1000000
input ("Have you taken CS261? (Yes or No): ") .upper ()
Transcribed Image Text:Traceback (most recent call last): File "/usercode/main.py", line 58, in module> ca261 answer EOFError: EOF when reading a line 1000000 input ("Have you taken CS261? (Yes or No): ") .upper ()
Expert Solution
Step 1: Determining CS Major Status and Calculating Earned Credit Hours

The scenario aims to determine whether a student is a Computer Science (CS) major and, if so, calculate their earned credit hours based on the CS courses they have taken.

  • The code validates user inputs to ensure they respond with "YES" or "NO," providing guidance if invalid input is entered.
  • It uses a loop (ask_question function) to repeatedly ask a question until a valid response is received.
  • The code maintains clarity and organization by separating questions and logic into functions (ask_question and main).
  • It provides feedback and a closing message to enhance the user experience.
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
JQuery and Javascript
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education