Its supposed to receive the cost and markup percentage as arguments,
calculates the retail price of the item, then returns three pieces of
information: the amount of the markup, the sales tax and the retail
price. To calculate the amount of the markup, multiply the
wholesale cost by the markup percentage. Then calculate the unit
price for the item by adding the wholesale cost to the amount of
the markup. The subtotal is the unit price times the quantity of the
purchase. The sales tax is 6% of the subtotal. The retail price is
the sum of the subtotal and the sales tax.
I'm unsure about how to go about the code for this, and once I have the function running properly, how to read it into the rest of the information.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
int main() {
string item, Done;
int unit;
double price;
ifstream costs ;
void displayWelcome();
double calculateCostInfo(double markupPer,double price); //unsure if this should be void or double
double getMarkup(string item);
costs.open("costs.txt") ;
costs >> item;
displayWelcome();
while (item != "Done"){
costs >> unit;
costs >> price;
//calculateCostInfo(15, price);
cout << fixed << setprecision(2);
cout << item << setw(10) << unit << setw(5) << "$" << price<< setw(10) << getMarkup(item) << '%'<< setw(7) << endl;
costs >> item;
}//end while
costs.close();
return 0;
}
void displayWelcome(){
cout << "***********************************************************************" << endl ;
cout << "* Welcome to ABX. I'm Patrick, your manager. *" << endl ;
cout << "* Here is a summary of your purchases. *" << endl ;
cout << "***********************************************************************" << endl << endl<<endl<<endl<<endl ;
cout << "Item Name" << setw(10) << "Quantity" << setw(12) <<"Unit Price" << setw(9)<< "Markup %" << setw(7)<<"Markup" << setw(7)<< "Tax" << setw(15)<<"Retail Price" <<endl;
}
//this is the area im confused about:
double calculateCostInfo(double markupPer,double price, double markupAmnt, double, double unitPrice, double subTotal, double tax, double retailPrice, int unit){
markupAmnt = markupPer * price ;
unitPrice = price + markupAmnt ;
subTotal = unitPrice * unit ;
tax = subTotal * 0.06 ;
retailPrice = subTotal + tax;
return markupAmnt, tax, retailPrice ;
}
double getMarkup(string item){
if (item == "Bracelet")
return 100;
else if (item =="Earrings")
return 100;
else if (item =="Necklace")
return 30;
else if (item =="ToeRing.")
return 5;
else if (item =="KeyFob..")
return 25;
else if (item =="Cufflink")
return 50;
else if (item =="Other")
return 0;
}
|