Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions