In: Computer Science
Using Python write a program that does the following in order:
1. Ask user to enter a name 2. Ask the user to enter five numbers “amount1”, “amount2”, “amount3”, “amount4”, “amount5” 3. Calculate the sum of the numbers “amount1”, “amount2”, “amount3”, “amount4”, “amount5” 4. If the sum is greater than 0, print out the sum 5. If the sum is equal to zero, print out “Your account balance is zero” 6. If the sum is less than 0, print out “Your account is overdrawn” and the “negative amount” 7. Round all print values to 1 decimal place Round your sum output to 2 decimal places
The Solution:
The Code:
name=input("Enter your Name: ")
print("Enter 5 numbers(amounts): ")
amount1=round(float(input("1: ")),1)
amount2=round(float(input("2: ")),1)
amount3=round(float(input("3: ")),1)
amount4=round(float(input("4: ")),1)
amount5=round(float(input("5: ")),1)
sum=round(amount1+amount2+amount3+amount4+amount5,2)
if sum>0:
print("Your Account Balance is: ",sum)
elif sum==0:
print("Your Account Balance is zero")
else:
print("Your Account is Overdrawn. Your Account Balance is:
",sum)
The Screenshots:
The Code:
The Output: