Imagine a fictitious Internet provider that keeps the following "anonymized" data about each of their customers and the services they purchase. The data is anonymous, as many modern data sets are, to allow the data to be processed with fewer privacy concerns.
Field
|
Data Type
|
Customer ID |
string |
StreamingMovies |
int |
StreamingTV |
int |
MultipleLines |
int |
MonthlyCharges |
double |
The fields are formatted as follows:
Customer
IDtakes the format one letter A-Z followed by 3 numbers 0-9. For example, A123, B777, C817 are all valid Customer IDs. Be sure tovalidatethis in the input.
StreamingMovies,
StreamingTVandMultipleLinesare boolean values represented by 0 (false) or 1 (true). For example, if the customer record has '1' for a StreamingMovies value, it means the customer subscribes to the StreamingMovies service.
MonthlyChargesis a floating point value, representing the customer's monthly bill.
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 ageneric
value-returningfunction to do these operations and return a 'Customer' data structure (struct). Call it
three times
from main -- once for each customer.
You may write a void function to output the result for a Customer struct, passed as a parameter to the function. Or do so in a code block in main -- your choice.
Here are the other requirements:
- Define a 'struct Customer' data type with the fields and types from the above table.
- In the output, include table column headings, correctly-spaced.
- The total of all column widths and the spaces separating them should not exceed 80 spaces.
- You can use either
cin >>
for the attributes orgetline().
- Serializedowntocustomers.txtas the last thing that your program does. If you do this right, the file should have 15lines -- 5 for each of the 3 objects.
In this assignment your program will only be writing to a file -- not reading the data later. We're doing this to practice "serializing" the data down to a file so we can read it again in future programs.
What to Submit in Canvas
Submit your CPP for grading -- no TXT files please.
Previous Module:
Week 11 - Structured Data (Gaddis Ch. 11)" aria-describedby="msf1-previous-desc" style="color: rgb(45, 59, 69); background: rgb(245, 245, 245); border: 1px solid rgb(199, 205, 209); border-radius: 3px; transition: background-color 0.2s ease-in-out 0s; display: inline-block; position: relative; padding: 8px 14px; margin-bottom: 0px; font-size: 1rem; line-height: 20px; text-align: center; vertical-align: middle; cursor: pointer; overflow: hidden; text-shadow: none; user-select: none; float: left;">PreviousChapter 12 Slides" style="float: right;">
Next