If they choose to show the report, for each sales person display the following: • amount sold • name • commission percent (with 2 decimals) • amount earned (with 2 decimals) Sample Output: ABC Company Report $ 10001 Barnes, Julia, 6.00% ($600.06) $ 4500 Lee, Emma, 4.50% ($202.50) $ 1001 Li, Vincent, 4.50% ($45.05) 2$ 5800 Retter, Adam T., 5.25% ($304.50) $ 999 Smith, Ada, 3.00% ($29.97) Total Sales: $22301 The Sales Report has been saved to "sales_report.txt" Write the array to an output file using the same format as shown above. Create the output file name from the input file name: take the input file name and add_report.txt to it. If the input file name is sales, the output file name with extension is sales_report.txt. Finally, release the memory (deallocate the array) and terminate the program.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Optional
For a more challenging assignment replace the index with a pointer where possible (as demonstrated in Example C below).
Note: Three ways to display an array:
A. Use an index
for ( i = 0; i < size; i++ )
{
cout << ary[i] << " ";
}
B. Use an index and pointer arithmetic: NEVER USE THIS STYLE!
for ( i = 0; i < size; i++ )
{
cout << * (ary + i) « " ";
}
C. Use a pointer
for ( pW = ary, pLast
ary + size - 1; pW <= pLast; pW++ )
{
cout << *pw << " ";
}
Transcribed Image Text:Optional For a more challenging assignment replace the index with a pointer where possible (as demonstrated in Example C below). Note: Three ways to display an array: A. Use an index for ( i = 0; i < size; i++ ) { cout << ary[i] << " "; } B. Use an index and pointer arithmetic: NEVER USE THIS STYLE! for ( i = 0; i < size; i++ ) { cout << * (ary + i) « " "; } C. Use a pointer for ( pW = ary, pLast ary + size - 1; pW <= pLast; pW++ ) { cout << *pw << " "; }
Prompt the user to enter the name of an input file, then add the extension .txt:
Enter input file name:
Read data from file into a dynamically allocated array of n Sales structures. You may assume that the input file is valid. The only validation
you are required to do is to check the number on the first line, and if it is 0 or negative, display display the following error message:
The array size is invalid.
The program ends here!
and terminate the program.
Show the following error message if the input file could not be opened:
Error opening the input file: sales may.txt.
Write a function to calculate the company's total sales according to the following specifications:
function name: calculateTotal
input parameters: the array of structures and its size
• output parameters: none
• returned value: the company's total sales (an integer). Show the array followed by the total sales to the screen (depending on the
user's choice).
Show Report (Y/N)?
Transcribed Image Text:Prompt the user to enter the name of an input file, then add the extension .txt: Enter input file name: Read data from file into a dynamically allocated array of n Sales structures. You may assume that the input file is valid. The only validation you are required to do is to check the number on the first line, and if it is 0 or negative, display display the following error message: The array size is invalid. The program ends here! and terminate the program. Show the following error message if the input file could not be opened: Error opening the input file: sales may.txt. Write a function to calculate the company's total sales according to the following specifications: function name: calculateTotal input parameters: the array of structures and its size • output parameters: none • returned value: the company's total sales (an integer). Show the array followed by the total sales to the screen (depending on the user's choice). Show Report (Y/N)?
If they choose to show the report, for each sales person display the following:
• amount sold
• name
• commission percent (with 2 decimals)
• amount earned (with 2 decimals)
Sample Output:
ABC Company Report
$ 10001 Barnes, Julia, 6.00% ($600.06)
4500 Lee, Emma, 4.50% ($202.50)
1001 Li, Vincent, 4.50% ($45.05)
5800 Retter, Adam T., 5.25% ($304.50)
999 Smith, Ada, 3.00% ($29.97)
Total Sales: $22301
The Sales Report has been saved to "sales_report.txt"
Write the array to an output file using the same format as shown above. Create the output file name from the input file name: take the input
file name and add _report.txt to it. If the input file name is sales, the output file name with extension is sales_report.txt.
Finally, release the memory (deallocate the array) and terminate the program.
Optional
For a more challenging assignment replace the index with a pointer where possible (as demonstrated in Example C below).
Note: Three ways to display an array:
Transcribed Image Text:If they choose to show the report, for each sales person display the following: • amount sold • name • commission percent (with 2 decimals) • amount earned (with 2 decimals) Sample Output: ABC Company Report $ 10001 Barnes, Julia, 6.00% ($600.06) 4500 Lee, Emma, 4.50% ($202.50) 1001 Li, Vincent, 4.50% ($45.05) 5800 Retter, Adam T., 5.25% ($304.50) 999 Smith, Ada, 3.00% ($29.97) Total Sales: $22301 The Sales Report has been saved to "sales_report.txt" Write the array to an output file using the same format as shown above. Create the output file name from the input file name: take the input file name and add _report.txt to it. If the input file name is sales, the output file name with extension is sales_report.txt. Finally, release the memory (deallocate the array) and terminate the program. Optional For a more challenging assignment replace the index with a pointer where possible (as demonstrated in Example C below). Note: Three ways to display an array:
4.4 Lab: Pointers and Arrays of Structures
The Salespeople Problem revisited:
Dynamically allocate the array of structures (using pointers and new).
Remove the sort function.
• Add a new function to calculate the company's total.
Floating point numbers are shown with 2 decimals.
Change some error messages.
Optional: for a more challenging assignment replace the index with a pointer where possible.
Salespeople for the ABC Company earn a commission based upon their sales. The commission rates are shown below:
Sales
Commission
$0 - 1000
3%
1001 - 5000
4.5%
5001 - 10,000
5.25%
over 10,000
6%
On the first line in the input file there is a positive integer representing the number of salespeople. On each of the following n lines there is
an amount followed by the sales person name, as shown below:
1001 Vincent Li;
10001 Julia Barnes ;
999 Ada Smith;
Transcribed Image Text:4.4 Lab: Pointers and Arrays of Structures The Salespeople Problem revisited: Dynamically allocate the array of structures (using pointers and new). Remove the sort function. • Add a new function to calculate the company's total. Floating point numbers are shown with 2 decimals. Change some error messages. Optional: for a more challenging assignment replace the index with a pointer where possible. Salespeople for the ABC Company earn a commission based upon their sales. The commission rates are shown below: Sales Commission $0 - 1000 3% 1001 - 5000 4.5% 5001 - 10,000 5.25% over 10,000 6% On the first line in the input file there is a positive integer representing the number of salespeople. On each of the following n lines there is an amount followed by the sales person name, as shown below: 1001 Vincent Li; 10001 Julia Barnes ; 999 Ada Smith;
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 8 steps with 8 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY