Qn1: You are asked to write a simple C program that will accept an integer value in the range of 5-95 and as a multiple of 5 representing the number of cents to give to a customer in their change. The program should calculate how many coins of each denomination and display this to the user. Valid coin values are 50, 20, 10 and 5. Your solution (program and algorithm) should be modular in nature. This requires the submission of a high-level algorithm and suitable decompositions of each step. Note that for this problem the principle of code reuse is particularly important and a significant number of marks are allocated to this. You should attempt to design your solution such that it consists of a relatively small number of functions that are as general in design as possible and you should have one function in particular that can be reused (called repeatedly) in order to solve the majority of the problem. If you find that you have developed a large number of functions which each performs a similar task (or have a lot of repeated code) then attempt to analyse your design to generalise the logic so that it may be reused.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

Qn1:

You are asked to write a simple C program that will accept an integer value in the range
of 5-95 and as a multiple of 5 representing the number of cents to give to a customer in
their change. The program should calculate how many coins of each denomination and
display this to the user. Valid coin values are 50, 20, 10 and 5. Your solution (program
and algorithm) should be modular in nature. This requires the submission of a high-level
algorithm and suitable decompositions of each step.

Note that for this problem the principle of code reuse is particularly important and a
significant number of marks are allocated to this. You should attempt to design your
solution such that it consists of a relatively small number of functions that are as general
in design as possible and you should have one function in particular that can be reused
(called repeatedly) in order to solve the majority of the problem. If you find that you
have developed a large number of functions which each performs a similar task (or have
a lot of repeated code) then attempt to analyse your design to generalise the logic so
that it may be reused. 

Q2 :

You are to extend your solution to Question 2 above by allowing the user to enter the
amount of change as dollars and cents as a double (real number). Valid dollar values
are 100, 50, 20, 10, 5, 2 and 1. You program should output the correct combination of
dollar and cent denominations required and should be able to work for any valid dollar
amounts. Cents amounts may be should be multiples of 5 as in the previous question.

In this question you will need to explicitly convert a double to an integer to break the
inputted double down to its component parts as integers. You can use the following
code as the basis for doing this:

float change;
int dollar, cents;

...

dollar = (int) change;
cents = (int) (((change – dollar)*100) + 0.5);


Again your solution for this problem should be modular. 

Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY