Answer to Question #7680 in C++ for Anna

Question #7680
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);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS