PrepAway - Latest Free Exam Questions & Answers

What should you do?

You work as the Enterprise application developer at Domain.com. The Domain.com network consists of a single Active Directory domain named Domain.com. All servers in the domain run Windows Server 2003. Your responsibilities at Domain.com include the design and development of application frameworks. Domain.com operates in the Inland Revenue services department. You are currently developing an income tax preparation application. This application should calculate income tax on the following basis:

To this end you create two Double variables. These are named income and tax respectively. What is now required is to choose an appropriate decision flow structure to implement the business rules.

What should you do? (Choose the appropriate code segment.)

PrepAway - Latest Free Exam Questions & Answers

A.
if (income <7500)
{
tax = 0.10*income;
}
else if (income <=30000)
{
tax = 0.15*(income – 7500) + 750;
}
else if (income <=72000)
{
tax = 0.25*(income – 30000) + 4200;
}
else
{
tax = 0.28*(income – 72000) + 15000;
}

B.
if (income <=7500)
{
tax = 0.10*income;
if (income <= 30000)
{
tax = 0.15*(income – 7500 + 750;
if (income <= 72000)
{
tax = 0.25*(income – 30000) + 4200;
}
else
{
tax = 0.28*(income – 72000) + 15000;
}
}
}

C.
switch ((int)income)
{
case 7500:
{
tax = 0.10*income;
break;
}
case 30000:
{
tax = 0.15*(income – 7400) + 750;
break;
}
case 72000:
{
tax = 0.25*(income – 30000) + 4200;
break;
}
default:
{
tax = 0.28*(income – 72000) + 15000;
break;
}
}

D.
if (income <= 7500)
{
tax = 0.10*income;
}
if (income <= 30000)
{
tax = 0.15*(income – 7500) + 750;
}
if (income <= 72000)
{
tax = 0.25*(income – 30000) + 42000;
}
if (income > 72000)
{
tax = 0.28*(income – 72000) + 15000;
}

Explanation:
When you make use of if-else statements then you control execution based on a single expression. In this case, if the income of an individual is less than or equal to $7,500, the tax variable is set to 10% of the value of the income variable. Execution then leaves the entire if-else black. If not, then the code will determine whether the income is less than or equal to $ 30,000. If so, then the tax variable is set to $750 + 15% of the income over $7,500 etc.
Incorrect answers:
B: You should not make use of nested if-statements because it will result in income less than $7,500 to be taxed as 25%.
C: You should not make use of switch-case statements because each statement can be used to test a single value, but not a range of values. This will then result in income of less than $ 7,500 to be taxed at 28%.
D: You should not make use of if statements as it will cause income of less than $7,500 to be taxed at 25%.


Leave a Reply