Question: Write a program that does the following: using strin and char int Prompts the user for a 1 2 - digit ( maximum ) double

Write a program that does the following: using strin and char int
Prompts the user for a 12-digit (maximum) double precision number.
(e.g.: 1234567890.12,-12345.67,1234.5, etc.)
Verifies that the input is valid:
o There are a maximum of 12 digits (excluding the sign and decimal point)
o All input digits are numeric with the following possible exceptions:
Minus sign (-) in the first position
Decimal point (.) in the 2nd or 3rd position before the end digit.
Fractions of more than 2 digit positions are truncated
Converts the number into a currency format using string manipulation. The format
for the two examples above: $1,234,567,890.12,-$12,345.67 and $1,234.50
Please note:
o Commas are placed at 3-digit intervals, counted from the position of the
decimal dot (.)
o A $ is placed in front (to the left) of a positive amount
o A $ is placed after the minus sign (-) of a negative amount
o 0 shall be treated in the same manner as a positive number
Displays the number in the currency format

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 Programming Questions!