Docsity

Assignment 8 Problems - Computer Science I | CSCI 1170, Assignments of Computer Science

Toggle sidebar
bg1
CSCI 1170, Summer 2009, Assignment 8, Due see class calendar
Problem Specification:
Write a C++ program to read an invoice number (integer), an item name (string), an item number
(integer), quantity ordered (integer), unit price (float), markup percent (float), shipping cost per
order (float). Compute the retail price (float), the adjusted retail price (float), the expected profit
(float) per item, the total cost of all units, total retail value of all items, total shipping costs, and
expected profit from sale of all items, The program should read the data from the file
/usr/local/home/accts/csal/public_html/summer.09/1170/olab8su09.dat Read data from this file
and process until end of file is encountered.
You must use a function RetailPrice to calculate the retail price. This function must be called from
the main program and has two input parameters and returns a float. The retail price is found from
the sum of the item unit price and the product of the unit price and the markup percent.
You must use a function AdjustedRetailPrice to calculate the adjusted retail price. This function
must be called from the main program and has three parameters: retail price (call by reference),
number of units ordered, shipping cost. If the shipping costs are 0% of the retail price per item,
then no adjustment is made to the retail price. If the shipping costs are between 0% and 2% of the
retail price per item, then a 5% adjustment is made to the retail price. . If the shipping costs are
between 2% and 5% of the retail price per item, then a 10% adjustment is made to the retail price.
If the shipping costs are between 5% and 10% of the retail price per item, then a 15% adjustment is
made to the retail price. . If the shipping costs are 10% or more of the retail price per item, then an
adjustment equal to the shipping costs are made to the retail price. Again, note the retail price is
changed. As an example, consider the input data below starting with the first record: 123 bolt 14
1000 0.455 0.35 9.14 For this data, to determine the shipping cost as a percentage of the retail
price (remember the initial retail price is just the unit cost times the markup percent which for this
example is 0.61425), we compute the following: (shipping cost / number of units ) / retail price per
unit, i.e., (9.14 /1000) / .61425 This gives a value of 0.0149 This number falls in the 0% to 2%
range. Hence the retail price is adjusted by an additional 5%, ie., 0.61425 * 1.05 giving adjusted
retail price of 0.6449625
You must use a function ItemProfit to calculate the expected profit per item. This function must be
called from the main program and has three input parameters and returns a float. The expected
profit is found from the difference of retail price and the unit price times the number of items.
Again, for the first example give below: 123 bolt 14 1000 0.455 0.35 9.14 and using the retail
priced calculated above, we have: (0.6449625 โ€“ 0.455) * 1000
In your main program as you read the records, you need to find the total cost of all units, total retail
value of all items, total shipping costs, and expected profit from sale of all items,
All of your printed item order output is to be done in the function OrderPrint called from the main
program. This OrderPrint function has input parameters for each items to be printed. This function
returns nothing.
pf3

Partial preview of the text

Download Assignment 8 Problems - Computer Science I | CSCI 1170 and more Assignments Computer Science in PDF only on Docsity!

CSCI 1170, Summer 2009, Assignment 8, Due see class calendar Problem Specification: Write a C++ program to read an invoice number (integer), an item name (string), an item number (integer), quantity ordered (integer), unit price (float), markup percent (float), shipping cost per order (float). Compute the retail price (float), the adjusted retail price (float), the expected profit (float) per item, the total cost of all units, total retail value of all items, total shipping costs, and expected profit from sale of all items, The program should read the data from the file /usr/local/home/accts/csal/public_html/summer.09/1170/olab8su09.dat Read data from this file and process until end of file is encountered. You must use a function RetailPrice to calculate the retail price. This function must be called from the main program and has two input parameters and returns a float. The retail price is found from the sum of the item unit price and the product of the unit price and the markup percent. You must use a function AdjustedRetailPrice to calculate the adjusted retail price. This function must be called from the main program and has three parameters: retail price (call by reference), number of units ordered, shipping cost. If the shipping costs are 0% of the retail price per item, then no adjustment is made to the retail price. If the shipping costs are between 0% and 2% of the retail price per item, then a 5% adjustment is made to the retail price.. If the shipping costs are between 2% and 5% of the retail price per item, then a 10% adjustment is made to the retail price. If the shipping costs are between 5% and 10% of the retail price per item, then a 15% adjustment is made to the retail price.. If the shipping costs are 10% or more of the retail price per item, then an adjustment equal to the shipping costs are made to the retail price. Again, note the retail price is changed. As an example, consider the input data below starting with the first record: 123 bolt 14 1000 0.455 0.35 9.14 For this data, to determine the shipping cost as a percentage of the retail price (remember the initial retail price is just the unit cost times the markup percent which for this example is 0.61425), we compute the following: (shipping cost / number of units ) / retail price per unit, i.e., (9.14 /1000) / .61425 This gives a value of 0.0149 This number falls in the 0% to 2% range. Hence the retail price is adjusted by an additional 5%, ie., 0.61425 * 1.05 giving adjusted retail price of 0. You must use a function ItemProfit to calculate the expected profit per item. This function must be called from the main program and has three input parameters and returns a float. The expected profit is found from the difference of retail price and the unit price times the number of items. Again, for the first example give below: 123 bolt 14 1000 0.455 0.35 9.14 and using the retail priced calculated above, we have: (0.6449625 โ€“ 0.455) * 1000 In your main program as you read the records, you need to find the total cost of all units, total retail value of all items, total shipping costs, and expected profit from sale of all items, All of your printed item order output is to be done in the function OrderPrint called from the main program. This OrderPrint function has input parameters for each items to be printed. This function returns nothing.

All of your totals for all orders output is to be done in the function TotalPrint called from the main program. This TotalPrint function has input parameters for each items to be printed. This function returns nothing. Create your program in OLA/olab8/olab8.cc Once you have debugged your program, turn it in as follows: Make sure you are in the directory OLA/olab ranger$ script myolab8.txt ranger$ aCC olab8.cc ranger$ a.out ranger$ exit ranger$ handin olab8 olab8.cc myolab8.txt The following is an example your OrderPrint. If the following data appears in the file: 123 bolt 14 1000 0.455 0.35 9. 456 bolt 16 1000 0.04 0.34 11. 234 screw 17 500 0.78 0.40 15. then the following output would be printed. Invoice# Item Name Item# Quantity $Unit Markup $Shipping $AdjRetail $Profit 123 bolt 14 1000 0.455 0.35 9.14 0.6449625 0. 456 bolt 16 1000 0.04 0.34 31.08 0.06164 0. 234 screw 17 500 0.78 0.40 15.07 1.2012 0. Total Cost: 885. Total Retail: 1307. Total Shipping: 55. Expected Profit: 366. OUTLINE of your program /* Name: enter you name here Assignment: Open Lab 8 Due Date: Monday 6/29/ Instructor: Dr. Cripps */ #include #include using namespace std; // The function definitions need to appear first, but you may not want to write them first // give the function definition for RetailPrice here as described above.