Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PROG 2 0 7 9 9 : Data Structures and Algorithm Dev in C Evaluation: 1 0 points. Change Calculator Write a C program that

PROG20799: Data Structures and Algorithm Dev in C
Evaluation: 10 points.
Change Calculator
Write a C program that calculates the change as follows:
1. Prompt the user for the amount of purchase, use variable name moneyOwed.
2. Prompt the user for the amount paid, use variable name moneyPaid.
3. Calculate the change in details. Declare an integer array change[] of size 5, where the 0th item
is the number of dollars, the 1st is the number of quarters, the 2nd is the number of dimes, the
3rd is the number of nickels, and 4th is the number of pennies. You must use a function called
calcChange, call it in main() as calcChange(moneyOwed, moneyPaid, change), to perform this
task.
4. Print out the results.
Requirements:
1. Follow the principle of modular design where all input/output statements must be in the main()
function.
2. Define the calcChange function in a separate C file named changeUtil.c along with its header
file changeUtil.h.
3. Report an error for negative numbers or zero input.
4. Report an error if money paid is not enough.
5. If error occurs, give the user another try.
6. Your program should be reasonably optimized: use proper data types, minimize the code.
7. Your program should have the following output (sample data here):
Evaluation:
Your assignment will be graded based on the following:
1. The program runs without errors (logic and syntax).
2. Functional requirements of the assignment are properly/completely met.
3. Formatting, comments, indentation and variable name conventions are adequately
followed.
Good luck! Prof: Abdullah A.

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

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions