Assignment 6
Due Tuesday, May 5 at 11:59pm on Canvas
Important: You
must only use concepts and methods taught in class to complete these
assignments. If you use any outside concepts, you will automatically
receive a 0.
Pair Programming Required - Or You Will Receive a 0
- Both partners fill in, sign, date, and submit the pair programming contract
- Only one partner submit the code.
- Upload the document(s) along with your Lab code to Canvas.
- Please make sure both your names are on your file (hint: use a proper Javadoc comment)
- If you need help finding a partner, please contact me as soon as possible.
Assignment 6: Money Matters (10 pts)
- Write a program in a file Money.java
- Begin with a correct Javadoc comment including your name and your partner's name, and the Assignment number.
- The purpose of this program is to convert a cost input for a particular product into dollars and cents.
- Ask the user to type in both a product and how much it costs in decimal numbers.
- Then print the price written as dollars and cents.
- Required: store the cost as a String to take advantage of the String methods length() and charAt().
- Required: use exactly one if statement and one else
statement (the use of two if statements and the use of else if are both
disallowed).
- The use of else if will result in a 0 on this assignment.
- The use of String methods we did not cover in class will result in a 0 on this assignment.
- Note that you can assume the user will always enter a price between $10.00 and $999.99
- Your program should work identically to the examples below (except the user may input different values):
Sample Output:Enter the name of a product: bulk bubble gum Enter the price: $29.95
bulk bubble gum cost is 29 dollars and 95 cents.
Sample Output:Enter the name of a product: the iPhone 8 Enter the price: $295.35
the iPhone 8 cost is 295 dollars and 35 cents. - When your program is complete, please upload it to Canvas.
|