Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

thanks Write a C++ program that will allow the user to enter a currency amount and validate that it is in a correct format. For

thanks
image text in transcribed
Write a C++ program that will allow the user to enter a currency amount and validate that it is in a correct format. For purposes of this program, the oorrect format of curency is the following: $1234 The $ sign followed by an integer number \$1234.56. The $ sign followed by a reel number. If a decimal point is included in the number, there must be exactly 2 digits to the right of the decimal point \$1,234.56 There can be commas to the right of the decimal point, but they must always be in the correct place (hint - there must be 3 integer values to the right of the comma. No commas atter the decimal point) -\$1.234.56. There can be a negative sign bofore the dollar sign 12e A one or two digit integer followed by a cent sign. Create a function that will do the validation and if valid, will coevert the number to a "double" asd return it to the calling function. Your main function should do the following: 1. Prompt the user to end a currency amount 2. Read the input into a C-Style string 3. Call the fanction you created above to convert the amount. If the amount is valid, then display the amount in the form of a real (double) amount 4. Prompt the user if they wish to enter a new value (yes / no)

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

Recommended Textbook for

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

What is backup withholding? What is its purpose?

Answered: 1 week ago

Question

5. Describe the visual representations, or models, of communication

Answered: 1 week ago