C++ Program

PROGRAM DESCRIPTION

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

 

The main attraction of Summerville SeaWorld™ is no longer simply a proposition anymore:  the Porpoise Pond is a great hit with the local water-fun crowd!  Your planning was critical to getting the project off the ground, so to speak, and lots of grinning kiddies all wet.  Congratulations!  But only now has the boss discovered a missing link in the business plan:  a way to analyze the receipts and categorize exactly how well the attraction is doing.  Time for one more great C++ program.  This is sure to cement your reputation, again so to speak
J, and ensure you will be in high demand by businesses all over the low country.

 

The company ticket sales information is all sent to a data file to record each day’s activity.  But since the data arrives electronically from approximately 7 – 10 sales booths, there is no way to record anything but the basic sales data.  No one has figured out a way to capture the summary data when a booth is shut down.  So, your program will access a daily sales file and work with the raw data.

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

 

RECORD DESCRIPTION

 

You’ll need a copy of the data file to work with—the file’s name is  ssw-sales.dat.  Once you have your solution and your project created, place the data file into the project subdirectory (the same place that you see the .CPP file).  Note:  if you are working with the shell provided by your instructor, this will have been taken care of already.

 

Each record in the file contains data on one sale to one customer.  Here is a description of each of the fields for all records:

 

FIELD                      TYPE         DESCRIPTION                                                                EXAMPLES

Date                         string          Date coded as a string                                                    10/11/2010

Ticket type              char            Single character code for the type of ticket                ‘C’, ‘J’, ‘A’   (Child, Junior,Adult)

Ticket quantity      int               How many tickets purchased—all of the same type

Coupon                   char            If customer had a discount coupon                             ‘Y’ or ‘N’

Ticket cost              double        Actual cost of the ticket(s)

 

Each record is on a separate line, and fields are separated by a space.

 

OUTPUT

 

For each record, display the following on one line:  a line number; the type of ticket sold—interpret the character and display either Child, Junior, or Adult; the quantity of tickets purchased; whether or not the customer had a discount coupon (display either YES or NO); the actual cost of the tickets—if the ticket is a Child ticket, then leave this entry blank, don’t display zeros; and the difference, if any, between the actual cost and what the user should have been charged.  (If the ticket is a Child ticket, leave the coupon and the actual charge columns blank:  there is no use displaying any of that for free tickets!)

 

The reason for the final column is that we have had some malfunctions in the ticket-selling equipment—at least, that’s what those minimum-wage ticket operators are saying—and we think that some tickets have been “underpriced”.  So, after you display the charged amount, the dollar value that came from the file, compute the actual amount that should have been charged.  Then, subtract the computed amount from the actual charge and display the difference.   (To remind you, adult tickets are $11.50 and junior tickets are $7.50 at full price.)

 

For example, suppose the ticket file has a sale for 6 Junior tickets and does not show any discount coupon.  That means the charged price for the tickets should have been $45.00.  But the file contains a charge of $33.75, a discounted price!  Someone’s selling tickets at a discount without approval!  The way this should look in the listing would be like line #4 in the listing below.  In the listing the fourth line shows we are short $11.25 for that particular ticket sale.

 

Display column headers at the top of the report so the table of ticket sales looks like, well, a table.  The listing should start out looking very similar to this for the actual file:

 

 #            TYPE                QTY         COUPON             ACTUAL CHG            DELTA

1            Adult                  2                NO                                          23.00                  0.00

2            Junior                 4                YES                                        22.50                  0.00

3            Child                  8

4            Junior                 6                NO                                          33.75              -11.25

 

 (NOTE:  dollar items in two decimal places and lined up right-justified.  And no entries for the Child tickets after the quantity column.)

 

Separate functions required.  There are two mandatory functions you must design and use in this program.  First, to display the type of ticket, like Adult or Junior, use a separate function to test the ticket type code and return the appropriate string to display:  do not do any output inside the function.  Main should be the only place that you print entries for the table on screen.  Second, use a separate function to compute the delta column:  calculate the true cost of the tickets; compute the difference between that and the actual charged value; and return the value to be displayed in the DELTA column.  These two functions are mandatory:  if you skip either one, your program will suffer a stiff point penalty.  The use of other functions is not mandatory, but highly encouraged.

 

When you’re finished processing individual sales records, clear the screen and display a polished final summary containing the following information:

 

Number of records included in the database (in the report, too, of course!)

Totals for each type of ticket:  for each type display the total number of tickets of that type and the total dollars received for that type.  (So, this means six separate totals, two for each ticket type.)

Total dollar sales overall.

Total dollar amount over or under the actual revenue.  (In other words the total of the delta column.)

Last, identify the ticket type that had the highest number of tickets sold and how many were sold.  Make this a separate “announcement” at the end of the report simply to highlight who is getting wettest in our new attraction!   For example:

 

“The largest ticket type sold was toddler tickets:  we sold a grand total of 79 toddler tickets.”

 

Note:  this is not the right answer for the data file you have, just an example of the output.  One other note:  be careful that you don’t make any changes to the data file, and then alter the code to reflect those changes.  Your instructor will be using an entirely separate data file whose format matches the file you have been given.  What that also means is that, if you “give up” on any part of the required logic and decide to just compute some answers and code those answers, that will be plain as day to your instructor!  In those circumstances, it would be better to simply skip that part of the output.

 

This C++ solution should be Program7 Solution name.  Zip the solution for submitting, as usual.

 

TURN IN:  a data dictionary for this program, a complete flowchart, and the zipped solution directory.  Submit everything using the Dropbox, of course.

 

EXTRA CREDIT (15 pts)

 

After your final summary, call another function to perform some additional analysis on the data file.  Reopen the file and calculate how much money we are “losing” with the coupon business.  For each ticket sold with the discounted coupon price, figure out the cost without the coupon and then the savings for each of those customers.  Add all of the savings values up to see how much revenue the coupon sale is costing us.  Display that total so the boss can see how much money was sacrificed to coupon sales and can possibly make a business decision:  we may need to curtail how often the coupons are printed or maybe reduce the value of a single coupon.  (I’m making this a separate file processing module so you don’t have to fold it into your original program.  Certainly, the best way to accomplish this task would be to do just that; but keep it separate for purposes of this extra credit.)  Make sure your flowchart includes this module.

Program7

PROGRAM DESCRIPTION

The main attraction of Summerville SeaWorld™ is no longer simply a proposition anymore: the Porpoise Pond is a great hit with the local water-fun crowd! Your planning was critical to getting the project off the ground, so to speak, and lots of grinning kiddies all wet. Congratulations! But only now has the boss discovered a missing link in the business plan: a way to analyze the receipts and categorize exactly how well the attraction is doing. Time for one more great C++ program. This is sure to cement your reputation, again so to speak (, and ensure you will be in high demand by businesses all over the low country.
The company ticket sales information is all sent to a data file to record each day’s activity. But since the data arrives electronically from approximately 7 – 10 sales booths, there is no way to record anything but the basic sales data. No one has figured out a way to capture the summary data when a booth is shut down. So, your program will access a daily sales file and work with the raw data.

RECORD DESCRIPTION

You’ll need a copy of the data file to work with—the file’s name is ssw-sales.dat. Once you have your solution and your project created, place the data file into the project subdirectory (the same place that you see the .CPP file). Note: if you are working with the shell provided by your instructor, this will have been taken care of already.
Each record in the file contains data on one sale to one customer. Here is a description of each of the fields for all records:

FIELD
TYPE
DESCRIPTION
EXAMPLES

Date
string
Date coded as a string
10/11/2010
Ticket type
char
Single character code for the type of ticket
‘C’, ‘J’, ‘A’ (Child, Junior,Adult)

Ticket quantity
int
How many tickets purchased—all of the same type
Coupon
char
If customer had a discount coupon
‘Y’ or ‘N’

Ticket cost
double
Actual cost of the ticket(s)

Each record is on a separate line, and fields are separated by a space.
OUTPUT

For each record, display the following on one line: a line number; the type of ticket sold—interpret the character and display either Child, Junior, or Adult; the quantity of tickets purchased; whether or not the customer had a discount coupon (display either YES or NO); the actual cost of the tickets—if the ticket is a Child ticket, then leave this entry blank, don’t display zeros; and the difference, if any, between the actual cost and what the user should have been charged. (If the ticket is a Child ticket, leave the coupon and the actual charge columns blank: there is no use displaying any of that for free tickets!)
The reason for the final column is that we have had some malfunctions in the ticket-selling equipment—at least, that’s what those minimum-wage ticket operators are saying—and we think that some tickets have been “underpriced”. So, after you display the charged amount, the dollar value that came from the file, compute the actual amount that should have been charged. Then, subtract the computed amount from the actual charge and display the difference. (To remind you, adult tickets are $11.50 and junior tickets are $7.50 at full price.)
For example, suppose the ticket file has a sale for 6 Junior tickets and does not show any discount coupon. That means the charged price for the tickets should have been $45.00. But the file contains a charge of $33.75, a discounted price! Someone’s selling tickets at a discount without approval! The way this should look in the listing would be like line #4 in the listing below. In the listing the fourth line shows we are short $11.25 for that particular ticket sale.
Display column headers at the top of the report so the table of ticket sales looks like, well, a table. The listing should start out looking very similar to this for the actual file:

#
TYPE
QTY
COUPON
ACTUAL CHG
DELTA

1
Adult
2
NO
23.00
0.00
2
Junior
4
YES
22.50
0.00
3
Child
8

4
Junior
6
NO
33.75
-11.25
(NOTE: dollar items in two decimal places and lined up right-justified. And no entries for the Child tickets after the quantity column.)

Separate functions required. There are two mandatory functions you must design and use in this program. First, to display the type of ticket, like Adult or Junior, use a separate function to test the ticket type code and return the appropriate string to display: do not do any output inside the function. Main should be the only place that you print entries for the table on screen. Second, use a separate function to compute the delta column: calculate the true cost of the tickets; compute the difference between that and the actual charged value; and return the value to be displayed in the DELTA column. These two functions are mandatory: if you skip either one, your program will suffer a stiff point penalty. The use of other functions is not mandatory, but highly encouraged.
When you’re finished processing individual sales records, clear the screen and display a polished final summary containing the following information:
Number of records included in the database (in the report, too, of course!)
Totals for each type of ticket: for each type display the total number of tickets of that type and the total dollars received for that type. (So, this means six separate totals, two for each ticket type.)
Total dollar sales overall.

Total dollar amount over or under the actual revenue. (In other words the total of the delta column.)

Last, identify the ticket type that had the highest number of tickets sold and how many were sold. Make this a separate “announcement” at the end of the report simply to highlight who is getting wettest in our new attraction! For example:

“The largest ticket type sold was toddler tickets: we sold a grand total of 79 toddler tickets.”

Note: this is not the right answer for the data file you have, just an example of the output. One other note: be careful that you don’t make any changes to the data file, and then alter the code to reflect those changes. Your instructor will be using an entirely separate data file whose format matches the file you have been given. What that also means is that, if you “give up” on any part of the required logic and decide to just compute some answers and code those answers, that will be plain as day to your instructor! In those circumstances, it would be better to simply skip that part of the output.
This C++ solution should be Program7 Solution name
. Zip the solution for submitting, as usual.

TURN IN: a data dictionary for this program, a complete flowchart, and the zipped solution directory. Submit everything using the Dropbox, of course.

EXTRA CREDIT (15 pts)

After your final summary, call another function to perform some additional analysis on the data file. Reopen the file and calculate how much money we are “losing” with the coupon business. For each ticket sold with the discounted coupon price, figure out the cost without the coupon and then the savings for each of those customers. Add all of the savings values up to see how much revenue the coupon sale is costing us. Display that total so the boss can see how much money was sacrificed to coupon sales and can possibly make a business decision: we may need to curtail how often the coupons are printed or maybe reduce the value of a single coupon. (I’m making this a separate file processing module so you don’t have to fold it into your original program. Certainly, the best way to accomplish this task would be to do just that; but keep it separate for purposes of this extra credit.) Make sure your flowchart includes this module.

#7

CPT 232—C++ PROGRAMMING I

Program #7

Due Date: _________________

Page 3 of 3

Shell for Process SSW Sales Solution.zip

Process SSW Sales Solution/Process SSW Sales Project/Analyze SSW Daily Sales.cpp

Process SSW Sales Solution/Process SSW Sales Project/Analyze SSW Daily Sales.cpp

//FILE : Analyze SSW Daily Sales.cpp

//PROG : 

//PURP : 

#include
 
< iostream >

#include
 
< iomanip >

#include
 
< fstream >

#include
 
< string >

using
 
namespace
 std
;

//Function prototypes

int
 main
()

{

    
//Input file stream object to read the data file

    ifstream salesIn
;

    
//Variables for the incoming fields

    string ticketDate
;

    
char
 ticketType
,
 coupon
;

    
int
 ticketQty
;

    
double
 ticketCost
;

    
//Any other variables you need are your responsibility to declare!

    
//Set up the output specs

    cout 
<<  fixed  <<  setprecision ( 2 );      //Open the data file     salesIn . open ( "ssw-sales.dat" );      if   ( salesIn . is_open ())      {          //Headers         cout  <<   "This is only a test run to read all of the records...\n"               <<   "Here are the first and last field of each record for\n"               <<   "purposes of verification.\n\n" ;          //Prime read:  read the first record of the data file         salesIn      >>
  ticketDate

                    
>>
  ticketType

                    
>>
  ticketQty

                    
>>
  coupon

                    
>>
  ticketCost
;

        
//Begin the central record-processing while loop

        
while
 
(
!
salesIn
.
eof
())

        
{

            
//Display the first and last field of each record for testing

            
//purposes only.  If all fields appear OK on screen, then you 

            
//should comment out this cout for later work

            cout 
<<  ticketDate  <<  setw ( 10 )   <<  ticketCost  <<  endl ;              //Here is where you will need to do all your processing for each record              //Everything you need to add, count, accumulate, display, etc              //needs to be done here (or in other functions!).              //When you get to the "Read the next record" code below,              //the current record vanishes!              //Read the next record (bottom of while loop)             salesIn      >>
  ticketDate

                        
>>
  ticketType

                        
>>
  ticketQty

                        
>>
  coupon

                        
>>
  ticketCost
;

        
}
 
//END OF RECORD PROCESSING WHILE LOOP

        
//Close the data file since we are done with it

        salesIn
.
close
();

        
//Display all totals next

        
//You should comment out this cout and either display the totals here,

        
//or better yet call a function to display the final report

        cout 
<<   "\n\nEnd of test run.\n" ;      } //END IF FILE OPENED      else    //File did not open         cout  <<   "The sales file did not open!\n" ;      return   0 ; } //END MAIN //Your other functions need to be defined here Process SSW Sales Solution/Process SSW Sales Project/Process SSW Sales Project.vcxproj Debug Win32 Release Win32 {19C88CFB-35C7-4437-AB84-6E1F2D5CB56D} Win32Proj ProcessSSWSalesProject Application true Unicode Application false true Unicode true false Level3 Disabled WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) Console true Level3 MaxSpeed true true WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) Console true true true Process SSW Sales Solution/Process SSW Sales Project/Process SSW Sales Project.vcxproj.filters {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hpp;hxx;hm;inl;inc;xsd {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms Source Files Process SSW Sales Solution/Process SSW Sales Project/Process SSW Sales Project.vcxproj.user Process SSW Sales Solution/Process SSW Sales Project/ssw-sales.dat 10/15/2011 A 2 N 23.0 10/15/2011 J 4 Y 22.5 10/15/2011 C 8 N 0 10/15/2011 J 6 N 33.75 10/15/2011 C 4 N 0 10/15/2011 J 8 N 60.0 10/15/2011 J 5 N 28.13 10/15/2011 A 4 Y 34.5 10/15/2011 C 3 N 0 10/15/2011 C 7 N 0 10/15/2011 J 10 Y 75.0 10/15/2011 J 2 N 11.25 10/15/2011 A 2 N 17.25 10/15/2011 C 4 N 0 10/15/2011 C 5 N 0 10/15/2011 J 6 N 45.0 Process SSW Sales Solution/Process SSW Sales Solution.sln Microsoft Visual Studio Solution File, Format Version 11.00 # Visual C++ Express 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Process SSW Sales Project", "Process SSW Sales Project\Process SSW Sales Project.vcxproj", "{19C88CFB-35C7-4437-AB84-6E1F2D5CB56D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {19C88CFB-35C7-4437-AB84-6E1F2D5CB56D}.Debug|Win32.ActiveCfg = Debug|Win32 {19C88CFB-35C7-4437-AB84-6E1F2D5CB56D}.Debug|Win32.Build.0 = Debug|Win32 {19C88CFB-35C7-4437-AB84-6E1F2D5CB56D}.Release|Win32.ActiveCfg = Release|Win32 {19C88CFB-35C7-4437-AB84-6E1F2D5CB56D}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal Process SSW Sales Solution/Process SSW Sales Solution.suo

Still stressed with your coursework?
Get quality coursework help from an expert!