Describe the way to develop a software tool which can compute McCabe’s V(G) valu
ID: 3768866 • Letter: D
Question
Describe the way to develop a software tool which can compute McCabe’s V(G) value of your program (or algorithm). In other word, your algorithm (or pseudo code) that explain how to calculate McCabe’s V(G) value and paths of your program. Explain the algorithms and data structure as detail as possible.
and this is my code ,please use it by different way than V(g) = P +1 or V(G)= E -N +2 . I want differnt way in this anwer.thank you.
// asma.cpp : Defines the entry point for the console application.
//
// asma1.cpp : Defines the entry point for the console application.
//
#include <iostream>
using namespace std;
double TaxRate (int INCOME, int N_Children)
{
if (INCOME<15000)
{
switch(N_Children)
{
case 0:
return INCOME*0.05;
break;
case 1:
return INCOME*0.03;
break;
case 2:
return INCOME*0.02;
break;
default:
//Do something
break;
}
}
else if (INCOME<25000)
{
switch(N_Children)
{
case 0:
return INCOME*0.10;
break;
case 1:
return INCOME*0.08;
break;
case 2:
return INCOME*0.06;
break;
default:
//Do something
break;
}
}
else if (INCOME<55000)
{
switch(N_Children)
{
case 0:
return INCOME*0.15;
break;
case 1:
return INCOME*0.12;
break;
case 2:
return INCOME*0.11;
break;
default:
//Do something
break;
}
}
else if (INCOME<105000)
{
switch(N_Children)
{
case 0:
return INCOME*0.25;
break;
case 1:
return INCOME*0.23;
break;
case 2:
return INCOME*0.20;
break;
default:
//Do something
break;
}
}
else if (INCOME<205000)
{
switch(N_Children)
{
case 0:
return INCOME*0.28;
break;
case 1:
return INCOME*0.25;
break;
case 2:
return INCOME*0.30;
break;
default:
//Do something
break;
}
}
else if (INCOME< 255000)
{
switch(N_Children)
{
case 0:
return INCOME*0.30;
break;
case 1:
return INCOME*0.28;
break;
case 2:
return INCOME*0.30;
break;
default:
//Do something
break;
}
}
else if (INCOME< 305000)
{
switch(N_Children)
{
case 0:
return INCOME*0.35;
break;
case 1:
return INCOME*0.30;
break;
case 2:
return INCOME*0.30;
break;
default:
//Do something
break;
}
}
else if (INCOME< 405000)
{
switch(N_Children)
{
case 0:
return INCOME*0.40;
break;
case 1:
return INCOME*0.35;
break;
case 2:
return INCOME*0.30;
break;
default:
//Do something
break;
}
}
else
{
return INCOME*0.50;
}
return 0;
} // end calculate of TAX
double calculate (char type_of_people, int N_Children, int Tax, int INCOME)
{
switch(type_of_people)
{
case 'n':
return Tax = TaxRate(INCOME,N_Children);
break;
case 'b':
if(INCOME>65000)
{
return Tax = Tax + TaxRate(INCOME,N_Children);
}
else
{
INCOME = INCOME*0.065;
return INCOME;
}
break;
case 'm':
return Tax = Tax + (TaxRate(INCOME,N_Children)-(TaxRate(INCOME,N_Children)*0.75));
break;
case 's':
return Tax = Tax + (TaxRate(INCOME,N_Children)-(TaxRate(INCOME,N_Children)*0.70));
default:
break;
//Do something
}}
int main()
{
char type_of_people;
double INCOME, N_Children;
double Tax,y;
cout<<"please write appropriate letter for your situation:-"<<endl;
cout<<endl;
cout<<" letter | your situation "<<endl;
cout<<" b | Blind " <<endl;
cout<<" m | Military "<<endl;
cout<<" s | Student " <<endl;
cout<<" n | non of all " <<endl;
cout<<endl;
cout<<"your letter is ";
cin>>type_of_people;
if (type_of_people!='b'&& type_of_people!='m'&& type_of_people!='n'&& type_of_people!='s')
cout<<"rong value"<<endl;
else
{
cout<<" your salary is: ";
cin>> INCOME;
if(INCOME<0)
cout<<"rong value must be positive"<<endl;
else
{
y=INCOME; //for store the value befor Social Security
cout<<"How many Children do you have? ";
cin>> N_Children;
INCOME = INCOME*0.065; // Social Security
if(type_of_people=='m')
INCOME =INCOME-INCOME*0.75; // Social Security for milintry
else
INCOME = INCOME;
Tax=INCOME;
cout<<"Social Security tax is : $"<<Tax<<endl;
Tax = calculate(type_of_people, N_Children, Tax, y);
cout<<"Tax you need to pay is: $"<<Tax<<endl;
}
}}
Explanation / Answer
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
void getData(char marital, int numChild, int& exempt, int& noOfPeople, double& groSalary, double& penAmt);
double taxAmount(double taxIncome, int perExempt, double taxRate);
int main()
{
double groSalary; //variable for gross salary
double penAmt; //variable for percent contributed to pension plan
int exempt; //variable for standard exemption
int noOfPeople; //variable for number of people
double taxIncome; //variable for taxable income
double taxRate; //variable for federal tax amount owed
getData(char marital, int numChild, int& exempt, int& noOfPeople, double& groSalary, double& penAmt);
double taxAmount(double, int, double);
cout << "Your federal tax owed is: " << taxRate << endl;
return 0;
}
void getData(char marital, int numChild, int& exempt, int& noOfPeople, double& groSalary, double& penAmt)
{
char marital; //variable for marital status
int numChild; //variable for the number of children under 14
cout << fixed << showpoint;
cout << setprecision(2);
cout << "Enter your marital status: 'M' for Married or 'S' for Single: ";
cin >> marital;
cout << endl;
if (marital == 'M' || marital == 'm')
{
cout << "Enter number of children under the age of 14 years: ";
cout <<endl;
cin >> numChild;
exempt = 7000;
noOfPeople = 2 + numChild;
}
else if (marital == 'S' || marital == 's')
{
exempt = 4000;
numChild = 0;
noOfPeople = 1;
}
cout << "Enter gross salary. (Enter combined salary for both spouses";
cout << "if married): ";
cout << endl;
cin >> groSalary;
cout << "Enter the percentage of your gross income which you have";
cout << " contributed to a pension fund (Only enter the amount if 6%";
cout << " or less of your combined gross income: ";
cout << endl;
cin >> penAmt;
if (penAmt > 6)
{
cout << "You may only enter a percentage which is greater or equal";
cout << " to 6. Enter the percentage of your gross income which you have";
cout << " contributed to a pension fund. (Only enter the amount if 6%";
cout << " or less of your combined gross income: ";
cout << endl;
cin >> penAmt;
}
}
double taxAmount(double taxRate, int perExempt, int noOfPeople, double taxRate)
{
double taxRate; //variable to store taxRate
double taxAmt; //variable to store total tax amount
int perExempt //variable for personal Exemptions
taxRate = 0;
perExempt = (noOfPeople * 1500) + exempt;
taxIncome = groSalary - (groSalary * (penAmt * .01)) - perExempt);
if (taxIncome <= 15000)
{taxRate = .15 * taxIncome;
}
else if (taxIncome > 15000 && taxIncome <= 40000)
{taxRate = ((taxIncome - 15000) * .25) + 2250;}
else{
taxRate = ((taxIncome - 40000) * .35) + 8460;
}
return taxRate;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.