Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN C PLEASE Write a function to calculate the number of coins to give as change for a transaction. You have to write a complete

IN C PLEASE

image text in transcribed

Write a function to calculate the number of coins to give as change for a transaction. You have to write a complete "C" program that compiles and runs in Codeblocks, but the function is the most important part to be evaluated in this question. The function must: - Receive the following parameters: price of the item including cents, and amount used as payment. - Calculate the number of Dollars, Quarters, Dimes, Nickels, and Pennies, to complete the change amount. - Print the number of each coins value needed to complete the change. The main must: - Prompt the user for the exact price of the item - Prompt the user for the sum of the bills that will be used for payment - Call the function passing the two values as paramenters. - Prompt the user AGAIN for the exact price of a NEW item (double). - If the user answers with a negative number (-1) then the program ends. - Otherwise you must prompt the user for the sum of the bills that will be used for payment of the NEW item (int) - The main keeps calling the function until the user answer to the exact price is a negative number Hints: In the function ... 1. Calculate the total number of cents needed for the change. (payment - price Tag) 2. For each type of coin starting with the biggest value calculate the number of coins needed for the change: for instance (numQuarters = numCents / 25) gives you the number of quarters. 3. After each number of coins calculation is completed, calculate the amount of change left, this is the remainder (changeLeft = numCents % 25 ) The following is an example of how your program should look when you execute it: Enter the item price tag: 9.55 Enter the payment in dollar bills: 10 The exact change is 45 cents. 1 Quarter. 2 Dimes. Enter the item price tag: 18.44 Enter the payment in dollar bills: 20 The exact change is 156 cents. 1 Dollar. 2 Quarters. 1 Nickel. 1 Penny. Enter the item price tag: 28.59 Enter the payment in dollar bills: 30 The exact change is 141 cents. 1 Dollar. 1 Quarter. 1 Dime. 1 Nickel. 1 Penny. Enter the item price tag: -1 execution time : 110.136 s Process returned o (0x0) Press any key to continue

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

OCA Oracle Database SQL Exam Guide Exam 1Z0-071

Authors: Steve O'Hearn

1st Edition

1259585492, 978-1259585494

More Books

Students also viewed these Databases questions

Question

Describe the five types of change.

Answered: 1 week ago

Question

Which team solution is more likely to be pursued and why?

Answered: 1 week ago

Question

4. I can tell when team members dont mean what they say.

Answered: 1 week ago