I need B asic program only!!!!! Thankyou. Using the Do...loop until, Write a pro
ID: 674546 • Letter: I
Question
I need Basic program only!!!!! Thankyou.
Using the Do...loop until, Write a program to input the salary. If the salary is over 100,000 then calculate the federal tax at 20% otherwise calculate the federal tax 15%. Display the federal tax.
Calculate the statetax at the rate of 5%
Also, Count the number of people who earned salaries in the following ranges.
1) More than 100000
2) More 50000 and less than 100000
3) More than 25000 and less than 50000
4) Below 25000
Ask the user if he/she wants to continue. If the user says “yes”, repeat the whole thing to fetch the salary of the next employee, calculate and display the federal tax, etc.
The program should also calculate the total federal tax and total state tax with held from all the employees. You can do this using accumulation concept.
Hint: Each time the computer calculates the federal tax for one employee, keep accumulating it.
Explanation / Answer
#include<iostream>
using namespace std;
int main()
{
double sal,fedtax,statetax,totfed=0,totstate=0;
int cnt1=0,cnt2=0,cnt3=0,cnt4=0;
char ch='y';
do
{
cout<<" Input you salary : $";
cin>>sal;
if(sal>=100000) //For counting federal tax and no. of people in different salary ranges
{
fedtax = sal*0.2;
cnt1++;
}
else if(sal<100000&&sal>0)
{
fedtax = sal*0.15;
if(sal>=50000) //For calulating no. of people in different salary ranges
cnt2++;
else if(sal>=25000&&sal<50000)
cnt3++;
else
cnt4++;
}
else
{
cout<<" Invalid value entered!!";
continue;
}
statetax=sal*0.05;
cout<<" The federal tax will be : $"<<fedtax;
cout<<" The state tax will be : $"<<statetax;
totfed = totfed+fedtax;
totstate = totstate+statetax;
cout<<" Do you want to continue entering more values? (y/n) : ";
cin>>ch;
}while(ch=='y'||ch=='Y');
cout<<" The number of people earning more than $100000 is : "<<cnt1;
cout<<" The number of people earning more than $50000 and less than $100000 is : "<<cnt2;
cout<<" The number of people earning more than $25000 and less than $50000 is : "<<cnt3;
cout<<" The number of people earning below $25000 is : "<<cnt4;
cout<<" The total federal tax is : $"<<totfed;
cout<<" The total state tax is : $"<<totstate;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.