How to invalidate non-numeric inputs?
I am attempting to complete the phone bill calculator for my C++ course. I have been provided the following:
Plan A:
Price: $39.99 per month.
Data allowance: Includes 4 gigabytes of data. Additional data costs $10 per gigabyte.
Plan B:
Price: $59.99 per month.
Data Allowance: Includes 8 gigabytes of data. Additional data costs $5 per gigabyte.
Plan C:
Price: $69.99 per month.
Data Allowance: Unlimited
I feel I am improperly implementing the switch cases as well as the if statements. On top of that, if the user inputs a non-numeric value for gigsUsed, the program displays the total based on the first else if statement. Example: user inputs “B” for gigsUsed. The output will show “The total amount due is $39.99. How can I make sure only valid numeric inputs will be taken? I apologize in advance for any silly errors being made both with my code and with posting this question, I am new to programming, and this is my first post to this site.