
CSCI 161: Introduction to Programming I
Lab 3: Coins (20 points)
Goals
- to use the basic concepts of variables and primitive data and arithmetic operators
Overview
1. Start a new project in Eclipse â call it âLab3Coinsâ (one word)
2. Start a new class within the new project, call it âCoinsâ
3. Using comments, write your name and information about this class and lab.
4. Notice that Eclipse will create the class called âCoinsâ and method called âmainâ for you.
Also notice the indentations that occur after each curly bracket.
5. Write a complete program which when given an integer number of cents, calculates the
minimum number of coins (quarters, dimes, nickels, and pennies) required to make
change. Use 99 cents for the calculation. Ensure your program works by testing other
values, but submit the version with 99 assigned to the appropriate variable. Display
output to the console.
6. Be sure to make use of the remainder (mod) operator, along with any other necessary
arithmetic operators. Ensure your program works for any number of non-negative cents
7. Run the program, and then submit your work to Hardy161 ï Lab3Coins. The file being
submitted should be Coins.java
Use good programming style: choose good variable identifiers, write comments, and use white
space to make your program readable â you will now also be graded on this.
Output Specification
Output the initial cents; and minimum number of quarters, dimes, nickels, and pennies. It's not a
big deal if plurals don't agree with the number of coins (e.g., "1 pennies").
Sample Output:
Your change for 63 cents is as follows:
quarter(s):2
dimes(s):3
nickel(s):3
penny(ies):3
OR you can have an output as follows:
This is your change for 63 cents: 2 quarter(s) 3 dime(s) 3 nickel(s) 3
penny(ies)
Input Specification
No input is required.
Required Methods
N/A.
Extra Credit
For those of you who feel ambitious (and brave) and want to investigate into building a program
that takes an input of the number of cents to produces change, here is a link to some resources.
Be sure to create a new project e.g. Lab3Coins2, with a new class e.g Coins2. Hand that in
separately to the âLab3CoinsInputâ for extra credit of 10 points. If the instructions are unclear to
you, consult me.