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++
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";
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.