Question
Write a C++ console application ( Program) that generates stock keeping units (SKUs) for selected car data. A SKU is an alphanumeric code created by
Write a C++ console application (Program) that
generates stock keeping units (SKUs) for selected car data. A SKU is an
alphanumeric code created by retailers to track their products. Unlike other codes,
a SKU may be any length or format. The car data comes from included file
CarData.txt which contains a header row and 5K detail rows:
ID Name Year Seats Fuel Transmission
0001 Maruti Swift Dzire VDI 2014 5 Diesel Manual
0002 Skoda Rapid 1.5 TDI Ambition 2014 5 Diesel Manual
0006 Hyundai Xcent 1.2 VTVT E Plus 2017 5 Gas Manual
0009 Toyota Etios VXD 2011 5 Diesel Manual
0010 Ford Figo Diesel Celebration Edition 2013 5 Diesel Manual
...
Here is the specification for the file:
Field Type Start End
ID string 0 9
Name string 10 65
Year string 66 75
Seats string 76 82
Fuel string 83 94
Transmission string 95 104
The application will read this file and write another file. Attempt to open the input
file. If it doesn't open, print an error message and end the application. If it does
open, attempt to open the output file. If it doesn't open, print an error message and
end the application. If it does open, read past the header row in the input file and
print a message that the application is reading from the input file and writing to the
output file. Loop through the input file, read each line at a time, and update the
number of lines read. For each line, use the substr function to parse it into its six
fields: ID, name, year, seats, fuel, and transmission. If the name begins with
"Ford", then generate a SKU for the car that concatenates the following parts:
"FRD-"
The last two digits of year field.
"-S" followed by the first character of seats field.
"F" followed by the first character of fuel field.
"T" followed by the first character of transmission field.
For example, for the following car:
0010 Ford Figo Diesel Celebration Edition 2013 5 Diesel Manual
The SKU will be:
FRD-13-S5FDTM
Update the number of SKUs generated. If the number generated is a multiple of
10, print the ID, SKU, and full name for the car. For every generated SKU, write
ID, SKU, and full name for the car. After the read loop, print the number of lines
read and written, and close the files. Define global constants for the input and
output file names, and from the file specification, the spot where each field starts
and the length of each field. The output should look like this:
Welcome to SKU Sentries
-----------------------
Reading lines from file 'CarData.txt'
and writing lines to file 'CarDataWithSKUs.txt' ...
0449 FRD-16-S5FGTM Ford Figo 1.2P Titanium Plus MT
0616 FRD-12-S5FDTM Ford Figo Diesel ZXI
...
6107 FRD-16-S5FDTM Ford Ecosport 1.5 Diesel Titanium
... line(s) read from file 'CarData.txt'.
... SKU(s) generated and written to file 'CarDataWithSKUs.txt'.
End of SKU Sentries
(*I need upload The CarData.txt file to you.Please tell me the email address so that I can send attached txt file to you)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started