Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

7.3: The Price is Right Write a program that reads in a price as a String, and then outputs the price in dollars and cents.

7.3: The Price is Right

  • Write a program that reads in a price as a String, and then outputs the price in dollars and cents.
  • Name your project PriceRight and create a class called PriceRight.java
  • For this program, you can assume that the user will enter in a price in either 10s or 100s of dollars. The price will never go above 999.99 or below 10.00.
  • Hint: read in the price as a String
  • Hint 2: Use the String methods (length and charAt) to calculate the length of the String and then break the String into dollars and cents.
  • Hint 3: You will need one if and one else statement to solve this problem
  • Your program should work identically to the example below:
Enter the price: 12.95 12 dollars and 95 cents. 
  • Alternately:
Enter the price: 174.35 174 dollars and 35 cents. 
  • When your program gives the same output as above (except the user may give different input).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions