In: Computer Science
Write a decision-making program with command-line interface to implement a housing-score calculator (inspired by the 2020 Nifty Decision Makers by Evan Peck)
Your program will consist of two functions:
A sample run of the program:
----------------------------------- HOUSING SCORE CALCULATOR ----------------------------------- QUESTION 1 What year are you? (1,2,3,4): 4 QUESTION 2 How old are you?: 25 QUESTION 3 Are you currently on probation? (Yes or No): No QUESTION 4 Are you Part-time or Full-time? (0 or 1): 1 QUESTION 5 What is your GPA?: 3.9 ----------------------------------- Your housing score is: 7 -----------------------------------
And another sample run of the program:
----------------------------------- HOUSING SCORE CALCULATOR ----------------------------------- QUESTION 1 What year are you? (1,2,3,4): 2 QUESTION 2 How old are you?: 19 QUESTION 3 Are you currently on probation? (Yes or No): Yes QUESTION 4 Are you Part-time or Full-time? (0 or 1): 0 QUESTION 5 What is your GPA?: 2.7 ----------------------------------- Your housing score is: 1 -----------------------------------
The grading script runs the whole program as well as each function separately ('unit tests') to determine correctness. As such, the function names must match exactly as indicated above (else, the scripts cannot find them).
Your program may assume that the input (from the user and to the functions) is always in the expected format.
# this list stores the answers to all 5 questions
answers=[]
def computeScore(answers):
score=0
score+=answers[0]
if answers[1]>23:
score+=1
if answers[2]=="Yes":
score-=1
score+=answers[3]
if answers[4]>3.5:
score+=1
return score
# all thee questions from 1 to 5 are asked
# all the answers are appended to the list
print("HOUSING SCORE CALCULATOR\n")
print("QUESTION 1")
answers.append(int(input("What year are you? (1,2,3,4): ")))
print("\nQUESTION 2")
answers.append(int(input("How old are you?: ")))
print("\nQUESTION 3")
answers.append(input("Are you currently on probation? (Yes or No): "))
print("\nQUESTION 4")
answers.append(int(input(" Are you Part-time or Full-time? (0 or 1): ")))
print("\nQUESTION 5")
answers.append(float(input("What is your GPA?: ")))
# computeScore function calculates the score on the basis of answers to the 5 questions
score=computeScore(answers)
# print the score
print("Your housing score is: ",score)
PLEASE LIKE THE SOLUTION :))
IF YOU HAVE ANY DOUBTS PLEASE MENTION IN THE COMMENT