[Solved]Lab Lesson Writing Program Hypothetical Acme Wholesale Copper Wire Company Acme Company Se Q37102139
Using C++ and CodeBlocks IDE





This lab lesson you are writing a program for the hypothetical Acme Wholesale Copper Wire Company. The Acme company sells spools of copper wiring for $100 each. Write a program that displays the status of an order This program will be reading in from cin and writing to cout. In this program you will need at least three functions, including main as one of the three. You must use function prototypes for all of the functions (except main) Read function You need to have a function that reads in the following data The number of spools ordered The number of spools currently in stock Any special shipping and handling charges (see description below) Your program needs to prompt for these values. The prompts are below under Sample with special shipping and handling Do not accept a number less than 1 for the number of spools ordered .Do not accept a number less than 0 for the number of spools in stock Do not accept a shipping and handling charge of less than 0. For each of these cases you will have to have a loop that issues an error message, prompts for the input value again, and checks the data for validity The normal shipping and handling is S11.88 per spool. You will have to ask if there is special shipping and handling. If there is you will need to read in the special shipping and handling charge Here are a couple of sample runs. One with the default shipping and handling and one with special shipping and handling Sample with default shipping. Assume the following input from cin: 10 100 Here are the prompts to read in the spools to be ordered, spools in stock and shipping and handling: Spools to be ordered Sp 013 in stock Special shipping and handling (y or n) Sample with special shipping and handling: Assume the following input from cin 10 100 9.99 Here is the output or the prompts to cout Spools to be ordered Spools in stock Special shipping and handling y or n) Shipping and handling amount Note that the Shipping and handling amount prompt is only written out if the input from cin was y from the Special shipping and handling(y or n) prompt If the input from the Shipping and handling amount is any value other than y (lower case y) you can assume the default shipping and handling amount. There is not validity checking for this value other than y and any other value (meaning no special shipping and handling) The read function needs to return three values spools to be ordered spools in stock shipping and handling (either the default value or one specified by the user) Since a function can only return one value we cannot return the values via the return statement. Instead you need to pass three variables to the read function and pass them by reference. That way the read function can update the actual variables passed to the read function. You not NOT use any global variables. error messages Here are the error messages that the read function may generate: Spools order must be 1 or more Spools in stock must be 0 or more The spool shipping and handling charge must be 0.0 or more The above processing is all done in the read function. The values you read into (for the spools ordered, spools in stock and the shipping and handling charge) all need to be passed to the read function by reference. This is needed because the read function will be updating all three variables and it needs access to the variables The returned shipping charge will either be the default charge of S11.88 per spool or the special shipping and handling charge (if requested) Display function You will also need a display function that takes the spools ordered, spools in stock and the shipping and handling charges. These values will not be changed by the function, so these can all be passed by value The display function needs to display: the number of spools (ordered) that are ready to ship from the current stock the number of spools on back-order (if the numbered ordered is greater than what is in stock) the subtotal of the spools ready to ship (the number ready to ship times $100) the total shipping and handling charges for the spools ready to ship the total of the order ready to ship The display function will output these values to cout Assume the number of spools ordered is 9 and there are 5 spools in stock. Assume the shipping cost is $10. The output would be as follows. All of the amounts should have two digits to the right of the decimal point and a leading S character. The total width of the number not including the S character) is 10 characters Spools to be ordered Spools in stoclk Special shipping and handling (y or n) Shipping and handling amount Spoola ready to ship: 5 Subtotal ready to ship: $ Shipping and handling: $ Total shipping charges:$ 500.00 50.00 550.00 The main function The main function is fairly simple. You need to call the read function and then pass the updated values to the display function. Here are some sample runs Sample run # 1 (valid input with special handling) Assume the following is read in from cin 10.0 The contents of cout Spools to be ordered Spools in stock Special shipping and handling (y or n) Shipping and handling amount Spools ready to ship: 5 Spools on back-order: 4 Subtotal ready to ship: shipping and handling: s Total shipping charges: $ 500.00 50.00 550.00 Sample run #2 (valid input, no special handling) The following is read in from cin 35 35 The following would be written to cout Spools to be ordered Spools in stock Special shipping and handling (y or n) Spools ready to ship: 35 Spools on back-order: 0 Subtotal ready to ship:3500.00 Shipping and handling: Total shipping charges: 3915.80 415.80 Sample run # 3 (invalid input) Assume the following is read in from cin 200 1 12 -0.01 5.99 The contents of cout after the run: Spools to be ordered Spools order must be 1 or more Spools to be ordered Spools in stock Spools in stock must be 0 or more Spools in stock Special shipping and handling (y or n) Shipping and handling amount The spool shipping and handling charge must be 0.0 or more shipping and handling Spools ready to ship: 12 Spools on back-order: 188 Subtotal ready to ship:1200.00 Shipping and handling: Total shipping charges: 1271.88 amount 71.88 Finally, do not include a system(“pause”) statement in your program. This will cause your verification steps to fail Note: that the system( “pause”) command runs the pause command on the computer where the program is running. The pause command is a Windows command. Your program will be run on a server in the cloud. The cloud server may be running a different operating system (such as Linux). Error message “Could not find main function Now that we are using functions some of the tests are unit tests. In the unit tests the zyBooks environment will call one or more of your functions directly. To do this it has to find your main function has a problem with this when your int man0 statement has a comment on it. oda For example If your main looks as follows int mainO // main function You will get an error message: Could not find main function You need to change your code to // main function int main If you do not make this change you will continue to fail the unit tests. Show transcribed image text This lab lesson you are writing a program for the hypothetical Acme Wholesale Copper Wire Company. The Acme company sells spools of copper wiring for $100 each. Write a program that displays the status of an order This program will be reading in from cin and writing to cout. In this program you will need at least three functions, including main as one of the three. You must use function prototypes for all of the functions (except main) Read function You need to have a function that reads in the following data The number of spools ordered The number of spools currently in stock Any special shipping and handling charges (see description below) Your program needs to prompt for these values. The prompts are below under Sample with special shipping and handling Do not accept a number less than 1 for the number of spools ordered .Do not accept a number less than 0 for the number of spools in stock Do not accept a shipping and handling charge of less than 0. For each of these cases you will have to have a loop that issues an error message, prompts for the input value again, and checks the data for validity The normal shipping and handling is S11.88 per spool. You will have to ask if there is special shipping and handling. If there is you will need to read in the special shipping and handling charge Here are a couple of sample runs. One with the default shipping and handling and one with special shipping and handling Sample with default shipping. Assume the following input from cin: 10 100 Here are the prompts to read in the spools to be ordered, spools in stock and shipping and handling: Spools to be ordered Sp 013 in stock Special shipping and handling (y or n) Sample with special shipping and handling: Assume the following input from cin 10 100 9.99 Here is the output or the prompts to cout Spools to be ordered Spools in stock Special shipping and handling y or n) Shipping and handling amount Note that the Shipping and handling amount prompt is only written out if the input from cin was y from the Special shipping and handling(y or n) prompt If the input from the Shipping and handling amount is any value other than y (lower case y) you can assume the default shipping and handling amount. There is not validity checking for this value other than y and any other value (meaning no special shipping and handling)
The read function needs to return three values spools to be ordered spools in stock shipping and handling (either the default value or one specified by the user) Since a function can only return one value we cannot return the values via the return statement. Instead you need to pass three variables to the read function and pass them by reference. That way the read function can update the actual variables passed to the read function. You not NOT use any global variables. error messages Here are the error messages that the read function may generate: Spools order must be 1 or more Spools in stock must be 0 or more The spool shipping and handling charge must be 0.0 or more The above processing is all done in the read function. The values you read into (for the spools ordered, spools in stock and the shipping and handling charge) all need to be passed to the read function by reference. This is needed because the read function will be updating all three variables and it needs access to the variables The returned shipping charge will either be the default charge of S11.88 per spool or the special shipping and handling charge (if requested) Display function You will also need a display function that takes the spools ordered, spools in stock and the shipping and handling charges. These values will not be changed by the function, so these can all be passed by value The display function needs to display: the number of spools (ordered) that are ready to ship from the current stock the number of spools on back-order (if the numbered ordered is greater than what is in stock) the subtotal of the spools ready to ship (the number ready to ship times $100) the total shipping and handling charges for the spools ready to ship the total of the order ready to ship The display function will output these values to cout Assume the number of spools ordered is 9 and there are 5 spools in stock. Assume the shipping cost is $10. The output would be as follows. All of the amounts should have two digits to the right of the decimal point and a leading S character. The total width of the number not including the S character) is 10 characters Spools to be ordered Spools in stoclk Special shipping and handling (y or n) Shipping and handling amount Spoola ready to ship: 5 Subtotal ready to ship: $ Shipping and handling: $ Total shipping charges:$ 500.00 50.00 550.00 The main function The main function is fairly simple. You need to call the read function and then pass the updated values to the display function. Here are some sample runs Sample run # 1 (valid input with special handling) Assume the following is read in from cin
10.0 The contents of cout Spools to be ordered Spools in stock Special shipping and handling (y or n) Shipping and handling amount Spools ready to ship: 5 Spools on back-order: 4 Subtotal ready to ship: shipping and handling: s Total shipping charges: $ 500.00 50.00 550.00 Sample run #2 (valid input, no special handling) The following is read in from cin 35 35 The following would be written to cout Spools to be ordered Spools in stock Special shipping and handling (y or n) Spools ready to ship: 35 Spools on back-order: 0 Subtotal ready to ship:3500.00 Shipping and handling: Total shipping charges: 3915.80 415.80 Sample run # 3 (invalid input) Assume the following is read in from cin 200 1 12 -0.01 5.99
The contents of cout after the run: Spools to be ordered Spools order must be 1 or more Spools to be ordered Spools in stock Spools in stock must be 0 or more Spools in stock Special shipping and handling (y or n) Shipping and handling amount The spool shipping and handling charge must be 0.0 or more shipping and handling Spools ready to ship: 12 Spools on back-order: 188 Subtotal ready to ship:1200.00 Shipping and handling: Total shipping charges: 1271.88 amount 71.88
Finally, do not include a system(“pause”) statement in your program. This will cause your verification steps to fail Note: that the system( “pause”) command runs the pause command on the computer where the program is running. The pause command is a Windows command. Your program will be run on a server in the cloud. The cloud server may be running a different operating system (such as Linux). Error message “Could not find main function Now that we are using functions some of the tests are unit tests. In the unit tests the zyBooks environment will call one or more of your functions directly. To do this it has to find your main function has a problem with this when your int man0 statement has a comment on it. oda For example If your main looks as follows int mainO // main function You will get an error message: Could not find main function You need to change your code to // main function int main If you do not make this change you will continue to fail the unit tests.
Expert Answer
Answer to This lab lesson you are writing a program for the hypothetical Acme Wholesale Copper Wire Company. The Acme company sell… . . .
OR

