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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
//Rebecca Carolina Katz
// Filename: lab7_b
//Lab 7 part b
//Modifying my code from lab 7 part a to use a function to do each of the calculations involving calcMarkup,
// calcSalesTax, and calcRetailPrice
#include <iostream>
#include <cmath>
using namespace std;
double calcMarkUp (double, double, double);
double calcSalesTax (double, double,double);
double calcRetailPrice (double, double, double);
double showResults( double,double, double );
int main()
{
cout << "Rebecca Carolina Katz, Lab 7 part B\n";
// Variable declarations
double wholesale_cost;
double Mark_up_percentage;
double Sales_tax_rate;
char run_the_program_again;
do
{
// Validating that the wholesale cost is a valid number
cout <<"Enter Wholesale Cost:";
cin>> wholesale_cost;
while (wholesale_cost<=0)
{
cout<<"Invalid Wholesale Cost must be a positive number"<< endl;
cout <<"Enter Wholesale Cost:";
cin>> wholesale_cost;
}
// Validating that the mark up percentage is a valid number
cout <<"Enter Mark-up Percentage:";
cin>> Mark_up_percentage;
while (Mark_up_percentage<=0)
{
cout<<"Invalid Mark-up Percentaget must be a positive number"<< endl;
cout <<"Enter Mark-up Percentage:";
cin>> Mark_up_percentage;
}
// Validating that the sales tax rate is a valid number
cout <<"Enter Sales_tax_rate:";
cin>> Sales_tax_rate;
while (Sales_tax_rate<=0)
{
cout<<"Invalid Sales_tax_rate must be a positive number"<< endl;
cout <<"Enter Sales_tax_rate:";
cin>> Sales_tax_rate;
}
showResults( wholesale_cost, Mark_up_percentage, Sales_tax_rate );
cout << "Do you want to run this program again? y or n\n";
cin >> run_the_program_again;
} while (run_the_program_again =='y' || run_the_program_again =='Y' );
cout << "\nGOODBYE\n";
}// end of main
double showResults(double wholesale_cost, double Mark_up_percentage, double Sales_tax_rate)
{
//Variable declarations
double Mark_Up_Amount;
double Sales_Tax_Amount;
double Retail_Price;
cout << "Inside Show Results\n\n";
cout << "WholeSale Cost : " ;
cout << wholesale_cost << endl;
cout << "\n\nMark Up Percentage : ";
cout << Mark_up_percentage << endl;
cout << "\n\nSales Tax Rate : ";
cout << Sales_tax_rate << endl;
Mark_Up_Amount = calcMarkUp(wholesale_cost, Mark_Up_Amount, );
cout << "\n\nMark Up Amount\n" ;
cout << Mark_Up_Amount << endl;
Sales_Tax_Amount = calcSalesTax(wholesale_cost, Mark_Up_Amount, Sales_tax_rate);
cout << "\n\nSales Tax Amount\n" ;
cout << Sales_Tax_Amount << endl;
Retail_Price = calcRetailPrice(wholesale_cost, Mark_Up_Amount, Sales_Tax_Amount);
cout << "\n\nRetail Price Amount\n" ;
cout << Retail_Price << endl;
}// end of show results
double calcMarkUp (double wholesale_cost, double Mark_up_percentage)
{
//Variable declarations
double Mark_Up_Amount;
Mark_Up_Amount=wholesale_cost*(Mark_up_percentage/100);
return Mark_Up_Amount;
}
double calcSalesTax (double wholesale_cost, double Mark_Up_Amount, double Sales_tax_rate)
{
//Variable declarations
double Sales_Tax_Amount;
Sales_Tax_Amount=(wholesale_cost+Mark_Up_Amount)*(Sales_tax_rate/100);
return Sales_Tax_Amount;
}
double calcRetailPrice(double wholesale_cost, double Mark_Up_Amount,
double Sales_Tax_Amount)
{
//Variable declarations
double Retail_Price;
Retail_Price=(wholesale_cost+Mark_Up_Amount+Sales_Tax_Amount);
return Retail_Price;
// after function calls
cout << "\n\nInside calcMarkUp\n\n";
cout << "\n\nInside calcSalesTax\n\n";
cout << "\n\nInside calcRetailPrice\n\n";
}
|