Write a function called plusTax that uses parameters that specify a price (in cents) and a tax rate (as a per?
Write a function called plusTax that uses parameters that specify a price (in cents) and a tax rate (as a percentage). The function calculates the amount of tax, and then adds the tax to the price and returns the total.
Note that the function must round the tax (and not truncate it). Thus, 100 cents w/ a tax rate of 4.2% is 104 cents, but 100 cents w/ a tax rate of 4.8% is rounded to 105 cents. Hint: cast the double to an int and use an if statement to decide whether or not to add a penny.
i need headerline help(prototype) and to write a function for it, so far i have this and i'm stuck, someone please help, thanks.
int cost = 100; //cost is 100 cents
double taxRate = 4.2; //tax is at 4.2 percent
cout << "With tax that is " << plusTax (cost, taxRate) << " cents." << endl;
//output: With tax that is 104 cents.
taxRate = 4.8; //tax is at 4.8 percent
cout << "With tax that is " << plusTax (cost, taxRate) << " cents." << endl;
//output: With tax that is 105 cents.
cout << endl;
note this is a C++ program.
1
Expert's answer
2012-03-27T09:30:25-0400
Note that the function must round the tax (and not truncate it). Thus, 100 cents w/ a tax rate of 4.2% is 104 cents, but 100 cents w/ a tax rate of 4.8% is rounded to 105 cents. Hint: cast the double to an int and use an if statement to decide whether or not to add a penny. & i need headerline help(prototype) and to write a function for it, so far i have this and i'm stuck, someone please help, thanks. & int cost = 100; //cost is 100 cents double taxRate = 4.2; //tax is at 4.2 percent cout << "With tax that is " << plusTax (cost, taxRate) << " cents." << endl; //output: With tax that is 104 cents. taxRate = 4.8; //tax is at 4.8 percent cout << "With tax that is " << plusTax (cost, taxRate) << " cents." << endl; //output: With tax that is 105 cents. cout << endl; & note this is a C++ program.
int plusTax(int,float);
int plusTax(int c, float taxR){ return c+((c* taxR/100.0)+.5); }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment