Question

7.3: The Price is Right Write a program that reads in a price as a String,...

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).
0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
7.3: The Price is Right Write a program that reads in a price as a String,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that reads a string from the user. Show the amount of a's in...

    Write a program that reads a string from the user. Show the amount of a's in the string on the screen. Hint: use if to check if the i position of the string is 'a' or 'A'. (In C++)

  • Write a program in C that reads a string of bits( so either a one or...

    Write a program in C that reads a string of bits( so either a one or zero) in from the user one char at a time using the function getChar, which returns a char. hint in order to convert a char to an int, subtract the character. Then store the bits into an array. start with this: #include "stdio.h" #define MAX_BITS 32 int main() { printf("Enter up to 32 bits (hit 'enter' to terminate early): "); char bit = getchar();...

  • IN PYTHON, Write a program that reads a string from the user containing a date in...

    IN PYTHON, Write a program that reads a string from the user containing a date in the form mm/dd/ yyyy. It should print the date in the form April 12, 2017. Hint: Get the "mm" from the user entered date "mm/dd/yyyy", then convert the "mm" into a month number. You may use an list month_list = ['January', 'February','March','April', 'May','June', 'July','August', 'September', 'October', 'November', 'December']. Use the month number you got from "mm" to get the month name.

  • a. Write a program that reads your id and full name and display. And also display...

    a. Write a program that reads your id and full name and display. And also display the index of first letter and last letter of your full name. b. Modify above program, Declare a string course, let your program read course from user, check if course is not equal to comp2002, clear the string otherwise concatenate course and "Computer Science Department". c. Modify above program declare a string college="". If string college is empty then assign a new string "College...

  • Write a C program RemoveWord.c that can remove a word from a given string (i.e. a...

    Write a C program RemoveWord.c that can remove a word from a given string (i.e. a line) entered by the user Sample output is as following: Please enter a string: This is the last homework. Please enter the word to be removed: is Result: This the last homework. Hint: The C library function gets reads a line from stdin and stores it into the string pointed to by str. char *gets(char *str)

  • Write a program that reads a string from the keyboard and tests whether it contains a...

    Write a program that reads a string from the keyboard and tests whether it contains a valid time. Display the time as described below if it is valid, otherwise display a message as described below. The input date should have the format hh:mm:ss (where hh = hour, mm = minutes and ss = seconds in a 24 hour clock, for example 23:47:55). Here are the input errors (exceptions) that your program should detect and deal with: Receive the input from...

  • Write a program that Reads a string from cin Prints the first and last letter without...

    Write a program that Reads a string from cin Prints the first and last letter without space in between, followed by endl For example, For an input seattle your program prints se(endl). For an input newyork your program prints nk (endl). You can assume that the length of the string is always greater than 1. LAB 0/10 ACTIVITY 1.9.1: Week2-4 Zip main.cpp Load default template. #include <iostream> using namespace std; 4int mainO 6 /* 8return Type your code here. /...

  • Take the following C++ code and add to it the following: Write a program that reads...

    Take the following C++ code and add to it the following: Write a program that reads a string and outputs the number of times each lowercase vowel appears in it. Your program must contain a function with one of its parameters as a char variable, and if the character is a vowel, it increments that vowel's count. #include<iostream> #include<string> using namespace std; int countVowel(char, char); int main(void) { string str1; int countA = 0; int countE = 0; int countI...

  • User Profiles Write a program that reads in a series of customer information -- including name,...

    User Profiles Write a program that reads in a series of customer information -- including name, gender, phone, email and password -- from a file and stores the information in an ArrayList of User objects. Once the information has been stored, the program should welcome a user and prompt him or her for an email and password The program should then use a linearSearch method to determine whether the user whose name and password entered match those of any of...

  • Please Answer Quickly Quantity discount program Write a MATLAB program that takes two inputs from the...

    Please Answer Quickly Quantity discount program Write a MATLAB program that takes two inputs from the user, Input 1: a decimal number that is a unit price (the price of one item) in dollars and cents Input 2: an integer that is the quantity of the item to purchase. The program prints 3 outputs, each on its own line: output 1: the total cost with no discount (unit price X quantity) output 2: the amount of discount in dollars and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT