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
|
#include <iostream>
#include <cmath>
#include <string.h>
#include <math.h>
using namespace std;
double itemValue(double item1, int quantity, double total);
double salesTax(double tax, double totalTax, double total);
double item1 = 4.75;
const double tax = 0.05;
int quantity;
int main()
{
double item1 = 0;
int quantity = 0;
double total = 0;
double tax = 0;
double totalTax = 0;
cout << "Thanks for shopping with us today, how many boxes of cereal were you looking to get? " << endl;
cin >> quantity;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout << "The price before tax is $ " << itemValue(item1, quantity, total) << " ." << endl;
cout << "\n The total price after tax is $ " << salesTax(tax, totalTax, total) << endl;
system("pause");
return 0;
}
double itemValue(double item1, int quantity, double total)
{
item1 = 4.25;
total = quantity * item1;
return total;
}
double salesTax(double tax, double totalTax, double total)
{
tax = 0.05;
cout << "We are applying the standard 5 percent tax to your purchase.";
totalTax = itemValue(item1, quantity, total) * tax;
return totalTax;
}
|