Question: MUST PASS ALL TEST CASES In Java Implement a function that will determine if a string represents a valid currency amount Such strings will have

 MUST PASS ALL TEST CASES In Java Implement a function that

MUST PASS ALL TEST CASES

In Java

Implement a function that will determine if a string represents a valid currency amount Such strings will have the following properties: * The amount must consist of base-10 digits * The amount may optionally contain thousands separators using the ',' character. * If thousands separators are present, they must be present at each thousands increment. * The amount must be prefixed by the currency symbol. We support US Dollars ($), Euros (), and Japanese Yen () only. * Negative amounts may be indicated either by a negative sign before the currency symbol or by enclosing the amount (including currency symbol) in parentheses, such as ($450) * Dollar and Euro amounts may contain an amount of cents, represented to exactly two digits of precision. * If a decimal point is present, the cents must be specified * Yen amounts may not contain decimal points * Amounts may not contain a leading zero, unless it is zero Dollars or Euros and cents are specified * Any other characters, including leading or trailing whitespace, is invalid Some examples: Valid: * "$450" * "-23" * "(x2400)" * "$4,500.00" * "0.25" Invalid: * "cat" *"25" "$45,0" "(350" "(-$3.50) "120.00

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!