#include <iostream>
using namespace std;

int getNumChild()
{
	int numChildren = 0;
	cout <<"How many children do you have? ";
	cin >> numChildren;
	return numChildren;
}

int calCredit(int numChildren, double income)
{
	int totCredit = 0;
	totCredit = numChildren * 1000;
	if (income < 70,000)
	{
		if (totCredit > 4000)
		{
			totCredit = 4000;
		}
	}
	return totCredit;
}

double getIncome()
{
	double income = 0.0;
	cout << "Please enter how much your yearly salary is: ";
	cin >> income;
	return income;
}


int main()
{
	int totCredit = 0;
	int numChildren = 0;
	double income = 0.0;

	numChildren = getNumChild ();
	income = getIncome ();
	totCredit = calCredit (numChildren, &income);

	cout << "Total child tax credit: " << totCredit << endl;

	system("PAUSE");
	return 0;
}

. A family can claim $1000 tax credit per child, but the total child tax credit cannot exceed $4000. Recently the tax law has changed. The $4000 upper limit applies only if the family income exceeds $70,000. In other words, families with income more than $70,000 can claim $4000 child tax credit at the most, but families with income $70,000 or less can claim more than $4000 child tax credit if there are more than 4 children ($1000 credit per child). Write a new program to calculate child tax credit. In addition to main(), also use the following two functions in your program:


I'm sorry to put this all on you guys, but i'm truly stuck and I could use any help I could get.

Thanks so much (and if i messed up with my post please let me know)

Recommended Answers

All 4 Replies

Where exactly are you stuck? Does it have anything to do with this function:

int calCredit(int numChildren, double income)
{
  int totCredit = 0;
  totCredit = numChildren * 1000;
  if (income < 70,000)
  {
    if (totCredit > 4000)
    {
      totCredit = 4000;
    }
  }
  return totCredit;
}

Because I can tell you right now, your conditional isn't correct... I suggest you take a closer look at your assignment's write-up.

Also, you also seem to have a lot of "magic numbers". I think you may want to define some constants. If you define them properly, I think it will help you get unstuck.

The stuck, which I should have stated, is with the condition. I need it to post 4,000 for who have more than 70,000 income. But its not working that way

I gathered as much. Your issue has nothing to do with your use of functions. It's a logic error.

Take another look at your conditional:

if (income < 70,000)
  {
    if (totCredit > 4000)
    {
      totCredit = 4000;
    }
  }

you have it backward. As written, it's applying the limit if they make less-than, instead of greater-than, $70K.

figrued it out. I was using 70,000 instead of 70000 without the comma. The comma was throwing me off. THanks for your reply.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.