4.5 Practice

Chapter Table of Contents

Ch. 4 Operators

Section Table of Contents


Billing Project

Make a program that sets the prices of 3 items. Your program should then print the price of each item and the sum of the prices (subtotal).

Then, apply an 8% sales tax on the subtotal. (To do this, multiply the subtotal by 0.08.) Print the tax.

Then sum the subtotal and tax to get the total. Print the total.

Output should be the following

Item 1 costs $5.25
Item 2 costs $7.25
Item 3 costs $10.5

Subtotal: $23.0
Tax: $1.84
Total: $24.84

Car Dealership

Manage a car dealership and take inventory of all cars sold! Use 3 integers to represent the prices of 3 cars. Then create another integer to sum the prices of those 3 cars. Finally, print out the formatted revenue after selling these 3 cars.

Example output if each car is $100 (note that your program should still work even if the cars are each a different price):

I sold 3 cars for $300


Copyright © 2021 Code 4 Tomorrow. All rights reserved. The code in this course is licensed under the MIT License. If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact classes@code4tomorrow.org for inquiries.