Question: Write a BNF definition for dollar amounts. Valid examples include: $0 $30 $53,469 $1,250,450 INVALID examples which should not be accepted by your definition include:
Write a BNF definition for dollar amounts.
- Valid examples include:
- $0
- $30
- $53,469
- $1,250,450
- INVALID examples which should not be accepted by your definition include:
- $00
- $01
- $0,500
- $01,500
- $1,43,935,0
- Note that a comma is always necessary for grouping every 3 numerals. There should be no leading zeros.
Below BNF code is what I've done so far. I'm stuck putting the commas grouping every 3 numerals.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
