64.1k views
0 votes
IN C++, write a program may execute the same computations repeatedly.The program below repeatedly asks the user to enter an annual salary, stopping when the user enters 0 or less. For each annual salary, the program determines the tax rate and computes the tax to pay.

1. Run the program below with annual salaries of 40000, 90000, and then 0.
2. Modify the program to use a while loop inside the given while loop. The new inner loop should repeatedly ask the user to enter a salary deduction, stopping when the user enters a 0 or less. The deductions are summed and then subtracted from the annual income, giving an adjusted gross income. The tax rate is then calculated from the adjusted gross income.
3. Run the program with the following input: 40000, 7000, 2000, 0, and 0. Note that the 7000 and 2000 are deductions.

User Alasha
by
4.4k points

1 Answer

2 votes

Answer:

Check the explanation

Step-by-step explanation:

c++ Program to find Gross salary after deducting tax from the annual salary

In this program user have to enter the annual salary,tax rate.This program continue to run repeatedly untill user gives 0 for annual salary.

#include <iostream>

using namespace std;

int main()

{

double asal,taxPay,trate;

char c;

while(true)

{

cout <<"Enter The Annual Salary ::";

cin>> asal;

if(asal<=0)

{

cout<<"* Program Exit *";

break;

}

cout<<"\\Enter Tax Rate::";

cin>>trate;

taxPay=asal*(trate/100);

cout<<"\\Tax You Have to pay::"<<taxPay<<endl;

}

}

_____________________

Kindly check the first attached image below for the code output.

2) Modified the above program

#include <iostream>

using namespace std;

int main()

{

double asal,taxPay,trate,deduction;

char c;

while(true)

{

cout <<"\\Enter The Annual Salary ::";

cin>> asal;

if(asal<=0)

{

cout<<"* Program Exit *";

break;

}

while(true)

{

cout<<"Enter Salary Deductions::";

cin>>deduction;

if(deduction<=0)

{

break;

}else

{

asal=asal-deduction;

}

}

cout<<"\\Enter Tax Rate::";

cin>>trate;

taxPay=asal*(trate/100);

cout<<"\\Tax You Have to pay::"<<taxPay<<endl;

cout<<"Salary remaining after all deductions::"<<asal;

}

return 0;

}

Kindly check the second attached image below for the code output.

IN C++, write a program may execute the same computations repeatedly.The program below-example-1
IN C++, write a program may execute the same computations repeatedly.The program below-example-2
User Joest
by
5.3k points