• Home
  • Blog
  • Diablo Valley College Customer Data Type of an Internet Provider Program

Diablo Valley College Customer Data Type of an Internet Provider Program

0 comments

Imgine a fictitious Internet provider that keeps the following “anonymized” data about each of their customers and the services they purchase. The data is completely anonymous (it doesn’t contain any names, addresses or personal information) as many modern data sets are, to allow the data to be processed with fewer privacy concerns.

Each customer record is a set of values:

Field Data Type
Customer ID string
HighSpeedInternet int
StreamingTV int
PhoneService int
MonthlyCharges double

Customer ID takes the format one letter A-Z followed by 3 numbers 0-9. For example, A123, B777, C817 are all valid Customer IDs. Be sure to validate this in the input when requested from the user — ask to repeat the input if it does not follow this format.

HighSpeedInternet, StreamingTV and PhoneService are boolean values represented by 0 (false) or 1 (true). For example, if the customer record has ‘1’ for a HighSpeedInternet value, it means the customer receives the high speed Internet service. This should also be validated.

MonthlyCharges is a floating point value, representing the customer’s monthly bill. Only validate that this is a positive number.

ASSIGNMENT

Write a C++ console program that prompts a user to enter attributes for three customers, and outputs the collected data in a formatted table.

Since the code block to prompt the user for attributes and store their values is to be used three times instead of just one, write a function that fills in a struct Customer and returns it, using either a return value or a reference variable. Call it three times from main — once for each customer.

Here are the other requirements:

  1. Define a ‘struct Customer’ data type with the fields and types from the above table.
  2. In the output, include table column headings, correctly-spaced.
  3. The total of all column widths and the spaces separating them should not exceed 80 spaces.
  4. You can use either cin >> for the attributes or getline().
  5. Output all of the data to customers.txt as the last thing that your program does. If you do this right, the file should have 15 lines — 5 for each of the 3 objects.

In this assignment your program will only be writing to a file — not reading the data at all. We’re doing this to practice “serializing” the data (writing it, piece by piece) down to a file so we can read it again in future programs.

About the Author

Follow me


{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}