Intro to Computer Science
PA01
Writing some simple programs
Code due to the Program Submission System on by 9/11 at 11:59pm.
Code can be submitted up to 2 days late with an automatic 10% deduction per day.
Introduction
Your book spends a lot of time talking about problem solving. Let's
look at how this would work, at least for some small problems.
Notes and requirements:
- Make sure that your program output looks exactly like the sample program output on this page. The autograder may have trouble giving you all the points if your output is formatted differently. Check your output spelling and spacing.
- Make sure that you are putting your name and the program header at the top of your programs. Look at the
Program Header Policy for more information.
- Use meaningful variable names. The variable name original_price is good, because I can tell what it represents. The variable name total2 is less good, because it is less descriptive.
- Your programs should ask for input in the exact order specified in the exercises below.
Program 1.1 (out of 5 points)
Create a program named originalPrice.py
- Get user input for sale price and percent reduction and report the original price for the item.
- For example, if the sale price was $13.99 and the percent reduction was 30% off, then the original price should be $19.99.
- Hint: Think about this as a ratio. In this example, 13.99 must be 70% of the original price. So, 13.99/? = 70/100
- Here is an example of exactly how your program should look when you run it in IDLE:
- If you type in different numbers when you run your program, your program should also use those new inputs. Take a look:
- Hint: You will want to use the round function to round cents to 2 decimal places. For example,
amount = round(amount,2)
rounds the variable amount to two decimal places and assigns the new, nicer number back into the variable named amount.
Program 1.2 (out of 8 points)
Create a program named parkingGarage.py
- Our parking garage payment machine accepts quarters and $1, $5, and $10 bills. When the machine makes change, it only makes change in quarters and $1 bills. Write a program to accept values for the charge and payment made and indicate the number of quarters and $1 bills to be returned. (Charges will always be a multiple of 25 cents.)
- Here is an example:
Program 1.3 (out of 12 points)
Create a program called fuelSavings.py
- I want to know how much I would save on fuel if I bought something more fuel efficient, e.g., a hybrid car. I think the numbers I need are miles driven per year, MPG in my current car, MPG of the new car, and the cost of gasoline. Report the fuel cost for each car and the savings (or loss--a negative number) with the new/hybrid car.
- Here is an example:
Final Submission
Please submit all three programs to the Program Submission System by the due date and time.