COP 3223 Introduction to C Summer Assignment 2




 This assignment is worth 60
points

 

Objectives:  The purpose
of this assignment, is for students to demonstrate knowledge of

•      
How to evaluate arithmetic expressions in C

•      
Arithmetic operators in C

•      
the basic template of a simple C program

•      
the syntax of the printf and scanf functions

•      
use of variables-  particularly declaration and assignment

•      
use of simple C syntax and semantics to create a
program that compiles and runs correctly

 

Problem:   Change Machine: You have just been
hired by the Green Leaf Software Company (GLSC) which produces both hardware
and software for the change machines used in most supermarkets.  Customers insert all of their small change,
pennies and dimes into the machine and they receive the equivalent value in the
largest possible denominations: single dollars, quarters, dimes, nickels and
pennies.  For example, if a customer
inserts 30 pennies, the machine will return 1 quarter and 1 nickel.    Your task is to program the change machine
for dealing with pennies.  When your
program is run, the user is prompted to enter the number of pennies that they
want changed (that is the number of pennies entered into the machine.   Your program should then output the money
returned by the machine in single dollars, quarters, dimes, nickels and
pennies.    

 

 

Sample run1

Please
enter the number of pennies that you have  
125


Your change is: dollar bills: 1 quarters: 1
dimes: 0 nickels: 0 pennies: 0


Thank
you


 

 

 

Sample run2

Please
enter the number of pennies that you have  
215


Your change is:  dollar bills: 2

 quarters: 0

 dimes: 1

 nickels: 1

 pennies: 0

Thank
you


 

Submission of Assignment

Please submit your code via
Webcourses by the deadline. No assignments will be accepted via email. 

Your submission should be a
single file called changemachine.c.   
Programs will be graded using

DevC++; so be sure that your code runs correctly in this
IDE, before submission.  If you do not
have DevC++ on your personal machine, you may use a computer in any campus lab
to test your code.

Above are 2 samples of what is expected when your code is
run.  The blue text represents the user
input.  The black text is what your
program should output when run.

 

Restrictions

1.      
You may assume that the user always enters a
valid number of pennies – that is a positive whole number

2.      
The input used to test your code is not limited
to the two examples provided in this document.

 
Powered by