I am getting the following errors
Error 1 error C2182: 'calculateTax' : illegal use of type 'void' 25
Error 2 error C2078: too many initializers 25
Error 4 error C2448: 'calculateTax' : function-style initializer appears to be a function definition 32
I edited so it would run...I didnt bother to see if it does what you want but it will run. Your function implementation is wrong, and your not testing a value when you do if(isFresno = true). Thats assigning isFresno to true you need ==
I have edited the code, but it is not giving me the answers I would expect to get. I tried to be more detailed about what I wanted to accomplish.
/*Write the code for a method named calculateTax that accepts
a double parameter named subTotal and a boolean parameter
named isFresno and calculates and returns the sales tax.
If isFresno is false, the sales tax should .0775.
If it's true, the sales tax should be increased by .001.
If the subTotal is less than or equal to zero,
an IllegalArgumentException should be thrown with the message
"Subtotal must be greater than zero."*/
int main()
{
double salesTax=0.0;
bool isFresno = false; //assigning the value of false
double num=0.0, sum=0.0;
cout<<"Enter number(s): ";
cin>>num;
while (num != -999)
{
sum = sum + num;
cin>>num;
}
if (sum > 100.0)
isFresno = true; //if sum is greater than 100, then//
//change value of isFresno to true//
calculateTax(sum, isFresno, salesTax);
cout<<"salesTax is "<<salesTax<<endl;
return 0;
}
void calculateTax(double subTotal, bool isFresno, double& salesTax)
{
int rate1 = (.0775 + .001);
int rate2 = .0775;
if (isFresno == true)
{
salesTax = subTotal * rate1;
cout<<"rate1 is "<<rate1<<endl;
}
else
{
salesTax = subTotal * rate2;
cout<<"rate2 is "<<rate2<<endl;
}