A special type of situation, called a controlled break, can occur when processing records of data must temporarily pause because a key value has changed.  For example, a control break might occur in a report that contains subtotals for groupings of records.   This program requires such a procedure.     Sales people at a local car dealership are paid by commission.  For every car sale, a sales person earns 30% of the base price or $100, whichever is higher.     Write a program that uses of a loop to read through and process records in a file.  Whenever the program encounters a new employee id, it should pause processing long enough to display the total of the previous employee’s commissions before processing the record just read.  After all records have been processed, the program should display a count of the records processed, the total sales, and the total commissions paid out. A sample output follows:                                         WEEKLY SALES REPORT Employee Retail Base  Commission 101    24125.00 1201.00     360.30 101     7650.00   350.00     105.00 101    38460.00 1517.00     455.10 ***Total Commission for 101:  920.40                                102 10500.00   500.00        150.00 102  7500.00   250.00        100.00 102 17551.00  1120.00        336.00 102 12400.00   400.00        120.00 ***Total Commission for 102:  706.00   103 41500.00   550.00        165.00 103 18670.00 1250.00        375.00 103 6700.00   250.00        100.00 103 17067.00 1018.00        305.40 ***Total Commission for 103:  945.40   Records:   11 Total Sales:  202123.00 Total Commissions:  2571.80   A sample input file, carsales.dat, to generate the report is shown below.  The first value in a line is the employee id.  The second value is the retail sale amount of the car (without tax.)  The third item is the base price on which the sales person’s commission is determined.  Note:  It is important that our data set is sorted by sales person id number.  If the data set is not sorted, the control-break process won't work.           101  24125  1201 101  7650  350 101  38460  1517 102  10500  500 102  7500 250 102  17551  1120 102  12400   400 103  41500   550 103  18670  1250 103  6700  250 103  17067  1018   Tips:   Make sure the input file exists prior to starting to process records. If the file does not exist, end the program. When we read the first record, we need to initialize a variable we will use to compare all following records against to see if the employee id has changed. Typically, we complete this step prior to starting the loop which processes all subsequent records. During normal processing, we accumulate a subtotal for the current sales person each time we loop. When the key field changes (and the control break occurs), we print the subtotal, reset the subtotal to 0, and reset the variable used to compare all following records to the new id number just read in. Once the last record is read in and the loop ends, we will need to perform one last subtotal line prior to printing summary totals.

Question

C++

A special type of situation, called a controlled break, can occur when processing records of data must temporarily pause because a key value has changed.  For example, a control break might occur in a report that contains subtotals for groupings of records.

 

This program requires such a procedure.  

 

Sales people at a local car dealership are paid by commission.  For every car sale, a sales person earns 30% of the base price or $100, whichever is higher.  

 

Write a program that uses of a loop to read through and process records in a file.  Whenever the program encounters a new employee id, it should pause processing long enough to display the total of the previous employee’s commissions before processing the record just read.  After all records have been processed, the program should display a count of the records processed, the total sales, and the total commissions paid out. A sample output follows:

 

                                      WEEKLY SALES REPORT

Employee Retail Base  Commission

101    24125.00 1201.00     360.30

101     7650.00   350.00     105.00

101    38460.00 1517.00     455.10

***Total Commission for 101:  920.40

 

                             102 10500.00   500.00        150.00

102  7500.00   250.00        100.00

102 17551.00  1120.00        336.00

102 12400.00   400.00        120.00

***Total Commission for 102:  706.00

 

103 41500.00   550.00        165.00

103 18670.00 1250.00        375.00

103 6700.00   250.00        100.00

103 17067.00 1018.00        305.40

***Total Commission for 103:  945.40

 

Records:   11

Total Sales:  202123.00

Total Commissions:  2571.80

 

A sample input file, carsales.dat, to generate the report is shown below.  The first value in a line is the employee id.  The second value is the retail sale amount of the car (without tax.)  The third item is the base price on which the sales person’s commission is determined.  Note:  It is important that our data set is sorted by sales person id number.  If the data set is not sorted, the control-break process won't work.

 

 

 

 

 

101 

24125  1201

101 

7650  350

101 

38460  1517

102 

10500  500

102 

7500 250

102 

17551  1120

102 

12400   400

103 

41500   550

103 

18670  1250

103 

6700  250

103 

17067  1018

 

Tips:

 

  • Make sure the input file exists prior to starting to process records. If the file does not exist, end the program.
  • When we read the first record, we need to initialize a variable we will use to compare all following records against to see if the employee id has changed. Typically, we complete this step prior to starting the loop which processes all subsequent records.
  • During normal processing, we accumulate a subtotal for the current sales person each time we loop. When the key field changes (and the control break occurs), we print the subtotal, reset the subtotal to 0, and reset the variable used to compare all following records to the new id number just read in.

Once the last record is read in and the loop ends, we will need to perform one last subtotal line prior to printing summary totals.

 

Expert Answer

Want to see the step-by-step answer?

Check out a sample Q&A here.

Want to see this answer and more?

Experts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*

*Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers and may be longer for promotional offers.
Tagged in
Engineering
Computer Science

Programing Language

Related Computer Science Q&A

Find answers to questions asked by students like you.

Q: Suppose you are an ad-serving company and you maintain a log of cookie data for ads to use on our we...

A: Actually, considering this situation cookies here refers to a small text file being placed on the ha...

Q: If you were Amazon how does having this data give you a competitive advantage vis-à-vis other ad-ser...

A: Competitive advantage: Having cookie data gives a person a competitive advantage because he can able...

Q: Briefly describe the what is meant by overflow and underflow conditions that might be produced after...

A: We know that floating point number are consist of addition,subtraction,multiplication and division a...

Q: A new PKI is being built at a company, but the network administrator has concerns about spikes of tr...

A: CRL

Q: A.  Show the 2’s complement binary (10 bits) representation of (-246)(10)B. Convert the following 2’...

A: Binary Number: The number system which has a base- 2 is called a binary number system. It has only 2...

Q: write a program to implement transformation of intersecting lines using c graphics?

A: // C program to demonstrate scaling of abjects #include<stdio.h> #include<graphics.h>  /...

Q: Write a Snort(Open Source Firewall),  IDS(Intrusion Detection System) custom rule to detect the Zeus...

A: Botnets made up of large number of malware infected clients computer and this is controlled by  remo...

Q: Course : Big Data Processing Material : BIG DATA LAYER ARCHITECTURE   Question: In general, What is ...

A: Big data Architecture:-                     Big data architecture is the foundation for big data ana...

Q: The Dash Cell Phone Company charges customers a basic rate of $5 per month to send text messages. Ad...

A: EXPLANATION: - The required variables like area_code = "", and text = "" are defined. Similarly, me...