Question: Create a program in C++ where you will have to validate inputs from a file. data.txt contains: 1 Gabriel Jesus 900000 GBJ 19 $9.29

Create a program in C++ where you will have to validate inputs from a file.

data.txt contains:

"

1 "Gabriel Jesus" 900000 GBJ 19 $9.29 2 Bill 3 Gabriel Jesus" 1 750000000 4 Bill 

1 James" 567 JH 456789 8

"

(You can create some invalid inputs in the file to test it out)

  • Check first character is digit 1-4
  • Check for space after digit
  • If digit = 1
    • Check for double quotes around the name
    • Check for 4 spaces after the second double quote
    • Check if the second field is all digits and is less than 10 digits
    • Check the third field has no white space and less than 4 characters
    • Check the fourth field is all digits and is less than 5 digits
    • Check the fifth field has dollar sign, decimal point, less than 5 digits before decimal point, 2 digits after decimal point
  • If digit = 3
    • Check for double quotes around name
    • Check for 2 spaces after second double quote
    • Check second field is digit 1-3
    • Check third field for length
      • If digit = 1
        • Check value is all digits and is less than 10 digits
      • If digit = 2
        • Check value has no white space and less than 4 characters
      • If digit = 3
        • Check value is all digits and is less than 5 digit

Create 3 boolean functions to validate and return true/false in main. Read the file line by line and send them to either one of these 3 functions depending on the first digit. If the first digit is 4 no action required

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!