Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Trying to figure out the \"expected an expression\" error at the if statement at

ID: 3572347 • Letter: T

Question

Trying to figure out the "expected an expression" error at the if statement at the start. I'm using c++, and this itself is a function. Just looking for the solution to this problem.

double monthlyPaycheck
{

   if (grossDepend < 192)
   {
       fedTax = grossDepend * 0.00;
   }
   else if (grossDepend < 960)
   {
       fedTax = (grossDepend - 192.00) * 0.10;
   }
   else if (grossDepend <3313)
   {
       fedTax = (grossDepend - 960.00) * 0.15 + 76.80;
   }
   else if (grossDepend < 7754)
   {          
       fedTax = (grossDepend - 3313.00) * 0.25 + 429.75;
   }
   else if (grossDepend < 15967)
   {
       fedTax = (grossDepend - 7754.00) * 0.28 + 1540;
   }
   else if (grossDepend < 34383)
   {
       fedTax = (grossDepend - 15967.00) * 0.33 + 3839.64;
   }
   else if (grossDepend < 34625)
   {
       fedTax = (grossDepend - 34483.00) * 0.35 + 9949.92;
   }
   else
   {
       fedTax = (grossDepend - 34625.00) * 0.396 + 9999.92;
   }
}

Explanation / Answer

if monthlyPaycheck is a function then function parameter ,variable declaration and return value are not present,

Here is function:

double monthlyPaycheck(double grossDepend)
{
double fedTax;
if (grossDepend < 192)
{
fedTax = grossDepend * 0.00;
}
else if (grossDepend < 960)
{
fedTax = (grossDepend - 192.00) * 0.10;
}
else if (grossDepend <3313)
{
fedTax = (grossDepend - 960.00) * 0.15 + 76.80;
}
else if (grossDepend < 7754)
{
fedTax = (grossDepend - 3313.00) * 0.25 + 429.75;
}
else if (grossDepend < 15967)
{
fedTax = (grossDepend - 7754.00) * 0.28 + 1540;
}
else if (grossDepend < 34383)
{
fedTax = (grossDepend - 15967.00) * 0.33 + 3839.64;
}
else if (grossDepend < 34625)
{
fedTax = (grossDepend - 34483.00) * 0.35 + 9949.92;
}
else
{
fedTax = (grossDepend - 34625.00) * 0.396 + 9999.92;
}
return fedTax;
}

Sample code to test:

#include <iostream>

using namespace std;
double monthlyPaycheck(double grossDepend)
{
double fedTax;
if (grossDepend < 192)
{
fedTax = grossDepend * 0.00;
}
else if (grossDepend < 960)
{
fedTax = (grossDepend - 192.00) * 0.10;
}
else if (grossDepend <3313)
{
fedTax = (grossDepend - 960.00) * 0.15 + 76.80;
}
else if (grossDepend < 7754)
{
fedTax = (grossDepend - 3313.00) * 0.25 + 429.75;
}
else if (grossDepend < 15967)
{
fedTax = (grossDepend - 7754.00) * 0.28 + 1540;
}
else if (grossDepend < 34383)
{
fedTax = (grossDepend - 15967.00) * 0.33 + 3839.64;
}
else if (grossDepend < 34625)
{
fedTax = (grossDepend - 34483.00) * 0.35 + 9949.92;
}
else
{
fedTax = (grossDepend - 34625.00) * 0.396 + 9999.92;
}
return fedTax;
}
int main()
{
//call monthlyPaycheck()
cout << monthlyPaycheck(10562.25) << endl;

return 0;
}

OUtput;

2326.31

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote