CS-200, Sample Final 1 PDF
CS-200, Sample Final 1 PDF
(Write your name on THIS PAGE ONLY!!!) (Write your ID# on this and every page!!!)
Instructions:
3. Write your STUDENT ID Number on every page. If you do not write your ID Number on a
certain page, you will not receive credit for the question on that page!
4. Do not write your name on any page (except this one). If you write your name on a certain page,
you will not receive credit for the question on that page!
5. There are 5 problems on the exam, one per page. Each problem is worth 20 points.
Once you start, verify you have all 5 problems.
6. You must give your answer to a question on the same sheet of paper that the problem appears
on. If you run out of space on the front of the page, you may continue to the back of that page
only. If you put your answer on a different page, you will not receive credit for that problem!
7. For problems that ask you to write a method, you must use the given method header exactly as
shown, and you do not need to write the main( ) method.
8. For problems that ask you to write code, you should only write the method indicated in the
problem. You can assume the following import statement and keyboard declarations:
import java.util.Scanner;
9. You may use "SOP" as an abbreviation for "System.out.print" and "SOPln" for
"System.out.println".
10. You do not need to do any error checking of input values, unless the problem specifically asks
you to do so!
11. If you are caught looking at other papers or communicating with other students in any way, you will
receive an F for the course.
WRITE your STUDENT ID# here: ____________________________
Problem 1 In US currency, a quarter is worth 25 cents, a nickel is worth 5 cents, and a penny is worth 1
cent. Write a Java program that prompts the user to enter an integer representing a dollar amount that
consists of all pennies. You may assume the user input value is greater than zero. The program is to
distribute that amount into quarters, nickels and pennies, using as few coins as possible. Note: you may not
use any currency values other than quarters, nickels, and pennies. Here are sample runs:
2 quarters 7 quarters
3 nickels 1 nickels
2 pennies 4 pennies
}
CS-200, Sample Final 1, Page 2 of 6.
WRITE your STUDENT ID# here: ____________________________
myArray 81 81 39 17 39 17 17 17 81 81 39 5 39 39
}
CS-200, Sample Final 1, Page 5 of 6.
WRITE your STUDENT ID# here: ____________________________