Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

FOR PYTHON: Description: Design a program that will accept a price in cents, e.g. 235 to represent a price such as$2.35. The amount must be

FOR PYTHON:

Description: Design a program that will accept a price in cents, e.g. 235 to represent a price such as$2.35. The amount must be a multiple of 5, since vending machines do not take pennies. (Your programmust check for valid input). The program should then figure out the number and type of coins that arerequired to purchase the item, using the guidelines given below. Write the program as a loop that stopswhen the user enters done (without the quotes).

Input: The user should be prompted for a price in cents. When the user is finished, he/she will enter theword done (no quotes).

Enter the price as cents, a multiple of five cents, or done (without quotes) if you are finished.

Output: If the user entered done, say goodbye and stop. Otherwise, print what the user entered,formatted properly as dollars and cents, and the coins needed to buy it.

Example: Good-Bye! [If entered done]

Examples: For a $2.35 item, you need: 2 dollars, 1 quarter, 1 dime

image text in transcribedimage text in transcribed

Procedure: 1. Prompt the user for a price in total cents or done a. If the user enters done, say Good-Bye and stop. Otherwise assume that the input is a price in cents, e.g. for $2.35 the user would input 235. Your program does not have to check for non-number-format input. b. You will need to convert the input to an integer for the coin calculations: e.g.: price nt(inprice) c. If the price entered is not an integer multiple of 5, print an error message and prompt for input again 2. Determine which coins are needed: a. dollars, quarters, dimes, nickels no pennies) b. 1 dollar 100 cents, 1 quarter 25 cents 1 dime 10 cents, 1 nickel 5 cents 3. Print the coins needed. a. Output format should resemble For a $n.nn item, you need: n dollars n quarters n dimes n nickels b. If you only need 1 of a coin, you must print the singular noun: For a $2.35 item, you need: 2 dollars 1 quarter 1 dime c. Do not print a line for anything you need 0 of d. You must properly print the price in dollars and cents, including the cases where the price is a whole dollar or multiple of 10 cents. For example, you must print $3.50, not $3.5

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_2

Step: 3

blur-text-image_3

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

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions