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
|
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
void input(long long&, float&, float&);
void tax_rate_calculator (float, float*);
float net_cost(float, float);
float call_tax(float, float);
float total_cost(float, float);
void processing(float, float, float, float, float);
void output(float, float, float, float, float);
int main()
{
string user_response = "y";
while (user_response == "y" || user_response == "Y")
{
long long cell_num;
float relays, call_length;
float net_cost, call_tax, total_cost;
input(cell_num, relays, call_length);
output(relays, call_length, net_cost, call_tax, total_cost);
return 0;
}
cout << endl << "Would you like to preform another calculation? (Y or N) ";
cin >> user_response;
}
void input(long long &cell_nump, float &relaysp, float &call_lengthp)
{
cout << " Field Format" << endl;
cout << "==============================================" << endl;
cout << "Cell Phone ";
cin >> cell_nump;
cout << "Number of Relay Stations ";
cin >> relaysp;
cout << "Minutes Used ";
cin >> call_lengthp;
}
void tax_rate_calculator(float relaysp, float tax_ratep)
{
if (0 <= relaysp <= 5)
{
tax_ratep = 0.01;
}
else if (6 <= relaysp <= 11)
{
tax_ratep = 0.03;
}
else if (12 <= relaysp <= 20)
{
tax_ratep = 0.05;
}
else if (21 <= relaysp <= 50)
{
tax_ratep = 0.08;
}
else if (relaysp > 50)
{
tax_ratep = 0.12;
}
}
float net_cost(float relaysp, float call_lengthp)
{
return(relaysp/50.0*0.40*call_lengthp);
}
float call_tax(float relaysp, float call_lengthp, float net_costp)
{
float tax_rate;
tax_rate_calculator(relaysp, tax_rate);
net_costp = net_cost(relaysp, call_lengthp);
return(net_costp*tax_rate);
}
float total_cost(float relaysp, float call_lengthp, float net_costp, float call_taxp)
{
net_costp = net_cost(relaysp, call_lengthp);
call_taxp = call_tax(relaysp, call_lengthp, net_costp);
return(net_costp+call_taxp);
}
void processing(float relaysp, float call_lengthp, float net_costp, float call_taxp, float total_costp)
{
net_cost(relaysp, call_lengthp);
call_tax(relaysp, call_lengthp, net_costp);
total_cost(relaysp, call_lengthp, net_costp, call_taxp);
}
void output(float relaysp, float call_lengthp, float net_costp, float call_taxp, float total_costp)
{
processing(relaysp, call_lengthp, net_costp, call_taxp, total_costp);
cout << setprecision(2) << fixed;
cout << "Net Cost " << net_costp << endl;
cout << "Call Tax " << call_taxp << endl;
cout << "Total Cost of Call " << total_costp << endl;
}
| |