MY CODE      print("--------------------------------") print("         UIC CS Track") print("--------------------------------") print() # Ask if the user is a CS major cs_major_answer = input("QUESTION 1\nAre you a CS major? (Yes or No): ").strip().upper() # Initialize earned credit hours to 0 earned_credit_hours = 0 # Check if the user is a CS major if cs_major_answer == "YES":     # Ask if the user has taken ENGR100     print("\nQUESTION 2")     engr100_answer = input("Have you taken ENGR100? (Yes or No): ").strip().upper()     # Check if the user has taken ENGR100     if engr100_answer == "YES":         # Increment earned credit hours by 0 for ENGR100         earned_credit_hours += 0     # Ask about "Level 1" CS classes     print("\nQUESTION 3")     cs111_answer = input("Have you taken CS111? (Yes or No): ").strip().upper()     if cs111_answer == "YES":         earned_credit_hours += 3         # Ask about "Level 2" CS classes         print("\nQUESTION 4")         cs141_answer = input("Have you taken CS141? (Yes or No): ").strip().upper()         if cs141_answer == "YES":             earned_credit_hours += 3             print("\nQUESTION 5")             cs151_answer = input("Have you taken CS151? (Yes or No): ").strip().upper()             if cs151_answer == "YES":                 earned_credit_hours += 3                 # Ask about "Level 3" CS classes                 print("\nQUESTION 6")                 cs211_answer = input("Have you taken CS211? (Yes or No): ").strip().upper()                 # Regardless of the answer to CS211, ask question 7                 print("\nQUESTION 7")                 cs251_answer = input("Have you taken CS251? (Yes or No): ").strip().upper()                 # Ask about CS277, CS377, and CS401 only if CS251 is taken                 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): ").strip().upper()                 if cs261_answer == "YES":                     earned_credit_hours += 4 # Display the summary print("\n--------------------------------") print("           Summary") print("--------------------------------") print() if cs_major_answer == "YES":     print("You are a CS major!")     print()     print("Required CS credits earned:", earned_credit_hours, end=".") else:     print("Sadly, you are not a CS major.") print() print("\nThank you for using App!") print("Closing app...")   ----------------------------------------------------------------------------- The only issue with this code is that it does not add credits correctly all the time... fix it so that the credits are added correctly while keeping the exact same format on the output...I'm pretty sure the issue has something to do with question 7 where it doesn't add correctly there

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

MY CODE   

 

print("--------------------------------")
print("         UIC CS Track")
print("--------------------------------")
print()

# Ask if the user is a CS major
cs_major_answer = input("QUESTION 1\nAre you a CS major? (Yes or No): ").strip().upper()

# Initialize earned credit hours to 0
earned_credit_hours = 0

# Check if the user is a CS major
if cs_major_answer == "YES":
    # Ask if the user has taken ENGR100
    print("\nQUESTION 2")
    engr100_answer = input("Have you taken ENGR100? (Yes or No): ").strip().upper()

    # Check if the user has taken ENGR100
    if engr100_answer == "YES":
        # Increment earned credit hours by 0 for ENGR100
        earned_credit_hours += 0

    # Ask about "Level 1" CS classes
    print("\nQUESTION 3")
    cs111_answer = input("Have you taken CS111? (Yes or No): ").strip().upper()

    if cs111_answer == "YES":
        earned_credit_hours += 3

        # Ask about "Level 2" CS classes
        print("\nQUESTION 4")
        cs141_answer = input("Have you taken CS141? (Yes or No): ").strip().upper()
        if cs141_answer == "YES":
            earned_credit_hours += 3

            print("\nQUESTION 5")
            cs151_answer = input("Have you taken CS151? (Yes or No): ").strip().upper()
            if cs151_answer == "YES":
                earned_credit_hours += 3

                # Ask about "Level 3" CS classes
                print("\nQUESTION 6")
                cs211_answer = input("Have you taken CS211? (Yes or No): ").strip().upper()

                # Regardless of the answer to CS211, ask question 7
                print("\nQUESTION 7")
                cs251_answer = input("Have you taken CS251? (Yes or No): ").strip().upper()

                # Ask about CS277, CS377, and CS401 only if CS251 is taken
                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): ").strip().upper()
                if cs261_answer == "YES":
                    earned_credit_hours += 4

# Display the summary
print("\n--------------------------------")
print("           Summary")
print("--------------------------------")
print()
if cs_major_answer == "YES":
    print("You are a CS major!")
    print()
    print("Required CS credits earned:", earned_credit_hours, end=".")
else:
    print("Sadly, you are not a CS major.")
print()
print("\nThank you for using App!")
print("Closing app...")
 
-----------------------------------------------------------------------------
The only issue with this code is that it does not add credits correctly all the time... fix it so that the credits are added correctly while keeping the exact same format on the output...I'm pretty sure the issue has something to do with question 7 where it doesn't add correctly there
Expert Solution
Step 1: The error in logic explained

The error in addition occurs due to the case CS401 which needs to be one indentation level to the right. The comments mention that - "Ask about CS277, CS377, and CS401 only if CS251 is taken".

Hence, the block of code pertaining to CS251 should be at the same indentation level as that of CS277, CS377.


trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 8 steps with 7 images

Blurred answer
Knowledge Booster
Multimedia tools and applications
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