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

Write a code to insert the salary then calculate the tax if the salary more than

ID: 3582569 • Letter: W

Question

Write a code to insert the salary then calculate the tax if the salary more than or equal 10000 the tax will be 10m if the salary less than 10000 the tax will be 5% finally, output the salary after subtract the tax The code must be as following The salary is inserted in the main function. Function called tax to calculate the tax based on the salary, this function will the tax. Function called salary after tax to calculate the salary after subtract the tax and output the salary after the tax. This function will not return any value. All variables are local variables do not use global variables.

Explanation / Answer

#include<iostream>
using namespace std;
float tax(int);                                                         //function declarations
void salary_after_tax(int,float);
int main()
{
int salary;float tax_percent;                                          //salary local variable declaration
cout<<"enter salary:";
cin>>salary;                                                          //user input:salary
tax_percent=tax(salary);                                              //tax calculating function calling

salary_after_tax(salary,tax_percent);                                  //calculating salary after deducting tax function calling

}
float tax(int salary)
{
if(salary>=10000)                                                   //checking whether salary >10000 or not
return 10.0/100.0;                                                    //returning 10%
else if(salary<10000)
    return 5.0/100.0;                                                       //returning 5%
    }
void salary_after_tax(int salary,float tax_percent)
{
cout<<"salary after subtracting tax:"<<salary-(salary*tax_percent);             //printing salary after subtracting tax amount
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote