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

answer these using C++ 2. Write a program to compute the income tax due based up

ID: 3886458 • Letter: A

Question


answer these using C++

2. Write a program to compute the income tax due based upon a table. The table contains a salary range, base tax and excess percentage Salary 0.00-1499.99 Base Tax 0.00 1500.00-2999.99 225.00 3000.00-4999.99 465.00 5000.00-7999.99 825.00 8000.00-9999.99 985.00 Percent of Excess 15% 16% 18% 20% 25% Given a salary, determine which range the salary is in, compute the tax as the Base Tax plus the Percent of Excess times the difference between the salary and the lower end of the range. For example, if the salary was $3200,00, then the tax is computes as: 465+ (3200-3000)18 3. Read in a character value for gender, i.e., 'm', 'M', 'r, 'E, Depending upon the gender value, print out a message "Hello Mr. Smith" or Hello Ms, Smithi", Write a program using an if-else construct, also using the conditional operator in the cout statement. 4. Write a program to test if a year is a leap year. A year is a leap year i Year is divisible by 4 and not by 100 or year is divisible by 400. For example, 1900 is not a leap year, 1996 is a leap year, 2000 is a leap year 5. Redo the gender salutation program using the switch construct.

Explanation / Answer

//2)
#include <iostream>
using namespace std;
int main() {

float income,tax,excess_percentage;
cout<<"Enter Income of person : ";//read the income from user
cin>>income;
if(income<=1499.99){
tax=0;excess_percentage=15.0;}
else if (income<=1500.00 || income>=2999.99){
tax=225;excess_percentage=16.0;income-=1500.00;}
else if (income<=3000.00 || income>=4999.99){
tax=465;excess_percentage=18.0;income-=3000.0;}
else if (income<=5000.00 || income>=7999.99){
tax=825;excess_percentage=20.0;income-=5000.0;}
else if (income<=8000.00 || income>=9999.99){
tax=985;excess_percentage=25.0;income-=8000;}

cout<<"Income = "<<income<<" ";
cout<<"TAX = "<<tax<<" ";
cout<<"total tax = "<<(tax+income)*excess_percentage<<" ";//calculate and print the output
}

//3)
#include <iostream>
using namespace std;

int main() {
char gender='f';
cout<<"Enter Gender(f/F or m/M) : ";
cin>>gender;
if(gender=='m'||gender=='M')
cout<<"Hello Mr.Smith";
else
cout<<"Hello Mrs.Smith";
}

//4)
#include <iostream>
using namespace std;

int main() {
int year;
cout<<"Enter yeaer : ";
cin>>year;
if((year%4)==0)
cout<<year<<" is leap year";
else
cout<<year<<" is not leap year";
}

//5)
#include <iostream>

using namespace std;
int main()
{
    char gender;
   
    cout<<"Enter gender (M/m or F/f): ";
    cin>>gender;
   
    switch (gender)
   {
      case 'm':   ; // ;

      case 'M':
         cout<<"male";
         break;

      case 'F': ; // ;

      case 'f':
         cout<<"female";
         break;
      default:
         cout<<"unknown";
   }
}