Question: Assignment 7.1: Money Matters (10 pts) This program converts a cost read for a particular product into dollars and cents. Ask the user to type

Assignment 7.1: Money Matters (10 pts)
This program converts a cost read 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.
I recommend you store the cost as a String to take advantage of the String methods length() and charAt().
For full credit, you must use exactly one if statement and one else statement (the use of two if statements and the use of else if are both disallowed).
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:
Sample Output:
Enter the name of a product: bubble gum
Enter the price: $29.95
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.
Please name your program Money.java.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!