[go: up one dir, main page]

0% found this document useful (0 votes)
19 views2 pages

Coding Exercise2

Uploaded by

23065469
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views2 pages

Coding Exercise2

Uploaded by

23065469
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

# Video Rental Store program

new_videos = int(input("Enter the number of new videos rented: "))


old_videos = int(input("Enter the number of oldies rented: "))

# Cost calculations
new_video_cost = 3.00
old_video_cost = 2.00
total_cost = (new_videos * new_video_cost) + (old_videos * old_video_cost)
print(f"Total cost for rentals: RM {total_cost:.2f}")

# Elapsed time program


elapsed_seconds = int(input("Enter the elapsed time in seconds: "))

# Convert seconds to hours, minutes, and seconds


hours = elapsed_seconds // 3600
remaining_seconds = elapsed_seconds % 3600
minutes = remaining_seconds // 60
seconds = remaining_seconds % 60

print(f"Elapsed time: {hours}:{minutes:02}:{seconds:02}")

# Yearly income and tax calculation program


income = float(input("Enter your yearly income (RM): "))

if income <= 2500:


tax = 0
elif income <= 10000:
tax = (income - 2500) * 0.05
elif income <= 50000:
tax = (income - 10000) * 0.15 + (10000 - 2500) * 0.05
else:
tax = (income - 50000) * 0.25 + (50000 - 10000) * 0.15 + (10000 - 2500) * 0.05

print(f"Total taxes to be paid: RM {tax:.2f}")


# Data plan charges program
data_usage = float(input("Enter your monthly data usage (in GB): "))

if data_usage <= 10:


charge = data_usage * 15
else:
charge = 10 * 15 + (data_usage - 10) * 30

print(f"Total data charges: RM {charge:.2f}")


# Area calculation program
choice = input("Enter 'R' for rectangle or 'C' for circle: ").lower()

if choice == 'r':
length = float(input("Enter the length of the rectangle: "))
width = float(input("Enter the width of the rectangle: "))
area = length * width
print(f"The area of the rectangle is: {area:.2f}")
elif choice == 'c':
radius = float(input("Enter the radius of the circle: "))
pi = 3.14159
area = pi * radius ** 2
print(f"The area of the circle is: {area:.2f}")
else:
print("Invalid choice.")
# Drink of the day program
day = int(input("Enter the day of the week (1 for Monday, 2 for Tuesday, etc.): "))

drinks = {
1: "Peppermint Mocha",
2: "Candy Bar Latte",
3: "Caramel Coffee",
4: "Chocolate Almond Cafe Au Lait",
5: "Pumpkin-Chai Latte",
6: "Vanilla Chai Tea",
7: "Gingerbread Latte"
}

drink_of_the_day = drinks.get(day, "Invalid day")


print(f"The drink of the day is: {drink_of_the_day}")

You might also like