Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python 1. Write a Program to Add Up Coins First, I want you to write a program that counts up coins. First, it should ask

Python

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

1. Write a Program to Add Up Coins First, I want you to write a program that counts up coins. First, it should ask the user to input the number of coins they have. Then for each coin the program should ask if it is a quarter, dime, nickel or penny (we'll ignore half dollar and dollar coins). Then you should output the number of dollars and cents they have. Here is an example of this program's output: How many coins do you have? 5 What is coin #1? (enter q for quarter, d for dime, n for nickel, p for penny): q What is coin #2? (enter q for quarter, d for dime, n for nickel, p for penny): q What is coin #3? (enter q for quarter, d for dime, n for nickel, p for penny): d What is coin #4? (enter q for quarter, d for dime, n for nickel, p for penny): n What is coin #5? (enter q for quarter, d for dime, n for nickel, p for penny): d You have 0 dollars and 75 cents. Wow, you are rich! Here is another example: How many coins do you have? 8 What is coin #1? (enter q for quarter, d for dime, n for nickel, p for penny): q What is coin #2? (enter q for quarter, d for dime, n for nickel, p for penny): q What is coin #3? (enter q for quarter, d for dime, n for nickel, p for penny): q What is coin #4? (enter q for quarter, d for dime, n for nickel, p for penny): q What is coin #5? (enter q for quarter, d for dime, n for nickel, p for penny): n What is coin #6? (enter q for quarter, d for dime, n for nickel, p for penny): d What is coin #7? (enter q for quarter, d for dime, n for nickel, p for penny): p What is coin #8? (enter q for quarter, d for dime, n for nickel, p for penny): q You have 1 dollars and 41 cents. Wow, you are rich! 1 Now this might seem like a convoluted way to count up someone's change you might prefer to ask how many quarters do you have?, how many dimes do you have?, and so on but I'm requiring you do it this way so that you will be get practice using loops. You should test your program to make sure it works in all instances. As we've talked about before, testing a program requires you to think about all the dif- ferent inputs that can come in and making sure your program works in all those cases. Note that you do NOT have to worry about instances where the user doesn't follow directions (so if the user inputs the letter Z when you ask her to input a coin you don't have to tell her Z is not a valid choice). Just focus on the legal inputs and how you will handle them. Thinking about the test cases beforehand might help you write the code too. Another piece of advice is to tackle the program in stages. receive the input from the user regarding the number of coins he has and create a loop to iterate that many times keep a running sum of the total number of cents every time the user inputs a new coin (similar to how you summed the rainfall in the last homework) take the number of cents and convert it to dollars and cents using % and // 2. Turn In Your First Program to Canvas Check list before you turn in your program: Name your file lastname_firstname_lab4a.py Comment at the top with your name Comment at the top describing the program in your own words 3. Grading Rubric Takes input from user (1 point) Loops the proper number of times (1 point) Correctly adds up the value of the coins (1 point) Properly displays the output in dollars and cents (1 point) Comments in program as described above (1 point)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions