題組內容
四、 Answer the following questions about C++ programming.
1. What is the output of the following partial code for the function and function call? Please explain
your answer in detail. (10 分)
void calculateCost(int count, float& subTotal, float taxCost);
float tax = 0.0,
subtotal = 0.0;
calculateCost(15, subtotal, tax);
cout << "The cost for 15 items is " << subtotal
<< ", and the tax for " << subtotal << " is " << tax << endl;
void calculateCost(int count, float& subTotal, float taxCost)
{
if (count < 10)
{
subTotal = count * 0.60;
}
else
{
subTotal = count * 0.35;
}
taxCost = 0.2 * subTotal;
}