TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Alexa White
NA
2
494
Need help with System.FormatException for bool
May 31 2018 10:04 PM
Hello I was wondering if anyone could help me with figuring out what is wrong with my code I keep getting an error output saying at the bool for the W2 and 1099. I need to make the program ask for 3 employees names, addresses, monthly gross income and whether they have a W2 or 1099 then based on that I have to calculate the taxes for a W2 and then the subcontractor doesn't have taxes taken. If anyone could give me a couple tips I would really appreciate it heres what I have so far:
using
System;
using
System.Collections.Generic;
using
System.Text;
using
System.Threading.Tasks;
using
System.Linq;
using
System.Threading;
namespace
MonthlyTaxCalculator3
{
class
Program
{
static
void
Main(
string
[] args)
{
const
double
Tax_Rate = 0.07;
// The percentage of tax, 7%, that is taken from Employee's monthly gross income.
Console.WriteLine(
"______________________________________________"
);
// Title and Header
Console.WriteLine(
" Monthly Gross Income Tax Calculator: employee Name #1 "
);
Console.WriteLine(
"______________________________________________"
);
// Title and Header
Console.Write(
"\n Welcome Software Developers! Please enter the first name: "
);
string
employeeName1 = Console.ReadLine();
// For obtianing the Software Developer's name.
Console.Write(
"\n Please enter your address listed on file: "
);
string
employeeAddress1 = Console.ReadLine();
// For obtaining the Software Developer's address that is listed on their employee file.
Console.Write(
"\n To calculate the 7% tax paid each month, please enter your annual monthly gross income: "
);
double
grossIncome1 = Convert.ToDouble(Console.ReadLine());
// For calculating the 7% tax paid from each of the Software Developer's annual monthly gross income.
Console.Write(
"\n What income type are you on a W2 or subcontractor: "
);
bool
incomeType1 = Convert.ToBoolean(Console.ReadLine());
// For obtaining the Software Developers income type
bool
[] incomeType = {
true
,
false
};
bool
W2 =
true
;
W2 = incomeType1;
bool
subcontractor =
false
;
subcontractor = incomeType1;
if
(incomeType1 == W2)
{
double
netIncomeTotal1 = CalculateGrossIncome1(grossIncome1, Tax_Rate);
double
taxesWithheld1 = CalculateTax1(grossIncome1, netIncomeTotal1);
double
netAnnualIncomeTotal1 = CalculateAnnualIncome1(grossIncome1, 12);
double
taxesWithheldAnnual1 = CalculateAnnualTax1(taxesWithheld1, 12);
// For calculating the 7% tax rate from the annual monthly gross income, and the amount of tax and amount of income left.
Console.WriteLine(
"\n\n Here is the annual monthly gross tax information summary: "
, employeeName1);
Console.WriteLine(
"\n Monthly Gross Income Before Taxes: {0:C2}"
, grossIncome1);
Console.WriteLine(
" Total Monthly Gross Income After Taxes Withheld: {0:C2}"
, taxesWithheld1);
Console.WriteLine(
" Monthly Net Income Taxes: {0:C2}"
, netIncomeTotal1);
Console.WriteLine(
"\n Annual Yearly Gross Income Before Taxes: {0:C2}"
, netAnnualIncomeTotal1);
Console.WriteLine(
" Total Annual Yearly Gross Income After Taxes Withheld: {0:C2}"
, taxesWithheldAnnual1);
}
else
{
double
netAnnualIncomeTotal1 = CalculateAnnualIncome1(grossIncome1, 12);
Console.WriteLine(
"\n\n Here is the annual monthly gross tax information summary: "
, employeeName1, employeeAddress1);
Console.WriteLine(
"\n Annual Yearly Gross Income Before Taxes: {0:C2}"
, netAnnualIncomeTotal1);
}
Console.ReadLine();
Console.ReadKey();
//
Console.WriteLine(
"______________________________________________"
);
// Title and Header
Console.WriteLine(
" Monthly Gross Income Tax Calculator: employee Name #2 "
);
Console.WriteLine(
"______________________________________________"
);
// Title and Header
Console.Write(
"\n Welcome Software Developers! Please enter the second name: "
);
string
employeeName2 = Console.ReadLine();
// For obtianing the Software Developer's name.
Console.Write(
"\n Please enter your address listed on file: "
);
string
employeeAddress2 = Console.ReadLine();
// For obtaining the Software Developer's address that is listed on their employee file.
Console.Write(
"\n To calculate the 7% tax paid each month, please enter your annual monthly gross income: "
);
double
grossIncome2 = Convert.ToDouble(Console.ReadLine());
// For calculating the 7% tax paid from each of the Software Developer's annual monthly gross income.
double
netIncomeTotal2 = CalculateGrossIncome2(grossIncome2, Tax_Rate);
double
taxesWithheld2 = CalculateTax2(grossIncome2, netIncomeTotal2);
double
netAnnualIncomeTotal2 = CalculateAnnualIncome2(grossIncome2, 12);
double
taxesWithheldAnnual2 = CalculateAnnualTax2(taxesWithheld2, 12);
// For calculating the 7% tax rate from the annual monthly gross income, and the amount of tax and amount of income left.
Console.WriteLine(
"\n\n Here is the annual monthly gross tax information summary: "
, employeeName2);
Console.WriteLine(
"\n Monthly Gross Income Before Taxes: {0:C2}"
, grossIncome2);
Console.WriteLine(
" Total Monthly Gross Income After Taxes Withheld: {0:C2}"
, taxesWithheld2);
Console.WriteLine(
" Monthly Net Income Taxes: {0:C2}"
, netIncomeTotal2);
Console.WriteLine(
"\n Annual Yearly Gross Income Before Taxes: {0:C2}"
, netAnnualIncomeTotal2);
Console.WriteLine(
" Total Annual Yearly Gross Income After Taxes Withheld: {0:C2}"
, taxesWithheldAnnual2);
Console.ReadLine();
//
Console.WriteLine(
"______________________________________________"
);
// Title and Header
Console.WriteLine(
" Monthly Gross Income Tax Calculator: employee Name #3 "
);
Console.WriteLine(
"______________________________________________"
);
// Title and Header
Console.Write(
"\n Welcome Software Developers! Please enter the third name: "
);
string
employeeName3 = Console.ReadLine();
// For obtianing the Software Developer's name.
Console.Write(
"\n Please enter your address listed on file: "
);
string
employeeAddress3 = Console.ReadLine();
// For obtaining the Software Developer's address that is listed on their employee file.
Console.Write(
"\n To calculate the 7% tax paid each month, please enter your annual monthly gross income: "
);
double
grossIncome3 = Convert.ToDouble(Console.ReadLine());
// For calculating the 7% tax paid from each of the Software Developer's annual monthly gross income.
Console.WriteLine(
"______________________________________________"
);
// Title and Header
double
netIncomeTotal3 = CalculateGrossIncome3(grossIncome3, Tax_Rate);
double
taxesWithheld3 = CalculateTax3(grossIncome3, netIncomeTotal3);
double
netAnnualIncomeTotal3 = CalculateAnnualIncome3(grossIncome3, 12);
double
taxesWithheldAnnual3 = CalculateAnnualTax3(taxesWithheld3, 12);
// For calculating the 7% tax rate from the annual monthly gross income, and the amount of tax and amount of income left.
Console.WriteLine(
"\n\n Here is the annual monthly gross tax information summary: "
, employeeName3);
Console.WriteLine(
"\n Monthly Gross Income Before Taxes: {0:C2}"
, grossIncome3);
Console.WriteLine(
" Total Monthly Gross Income After Taxes Withheld: {0:C2}"
, taxesWithheld3);
Console.WriteLine(
" Monthly Net Income Taxes: {0:C2}"
, netIncomeTotal3);
Console.WriteLine(
"\n Annual Yearly Gross Income Before Taxes: {0:C2}"
, netAnnualIncomeTotal3);
Console.WriteLine(
" Total Annual Yearly Gross Income After Taxes Withheld: {0:C2}"
, taxesWithheldAnnual3);
Console.ReadLine();
//
}
static
bool
incomeType1(
double
v)
{
throw
new
FormatException();
}
private
static
double
CalculateGrossIncome1(
double
v)
{
throw
new
NotImplementedException();
}
static
double
CalculateGrossIncome1(
double
GrossIncome1,
double
Tax_Rate)
{
return
GrossIncome1 * Tax_Rate;
}
// For the calculations of what was made after taxes have been taken.
private
static
double
CalculateTax1(
double
v)
{
throw
new
NotImplementedException();
}
static
double
CalculateTax1(
double
GrossIncome1,
double
NetIncomeTotal1)
{
return
GrossIncome1 - NetIncomeTotal1;
}
// For the calculations of the amount of taxes that have been taken out.
static
double
CalculateAnnualIncome1(
double
NetIncomeTotal1,
double
AnnualIncome1)
{
return
NetIncomeTotal1 * 12;
}
// For the calculations of what was made after taxes have been taken.
static
double
CalculateAnnualTax1(
double
TaxesWithheld1,
double
TaxesWithheldAnnual1)
{
return
TaxesWithheld1 * 12;
}
// For the calculations of the amount of taxes that have been taken out.
private
static
double
CalculateGrossIncome2(
double
v)
{
throw
new
NotImplementedException();
}
static
double
CalculateGrossIncome2(
double
GrossIncome2,
double
Tax_Rate)
{
return
GrossIncome2 * Tax_Rate;
}
// For the calculations of what was made after taxes have been taken.
private
static
double
CalculateTax2(
double
v)
{
throw
new
NotImplementedException();
}
static
double
CalculateTax2(
double
GrossIncome2,
double
NetIncomeTotal2)
{
return
GrossIncome2 - NetIncomeTotal2;
}
// For the calculations of the amount of taxes that have been taken out.
static
double
CalculateAnnualIncome2(
double
NetIncomeTotal2,
double
AnnualIncome2)
{
return
NetIncomeTotal2 * 12;
}
// For the calculations of what was made after taxes have been taken.
static
double
CalculateAnnualTax2(
double
TaxesWithheldAnnual2,
double
TaxesWithheld2)
{
return
TaxesWithheld2 * 12;
}
// For the calculations of the amount of taxes that have been taken out.
private
static
double
CalculateGrossIncome3(
double
v)
{
throw
new
NotImplementedException();
}
static
double
CalculateGrossIncome3(
double
GrossIncome3,
double
Tax_Rate)
{
return
GrossIncome3 * Tax_Rate;
}
// For the calculations of what was made after taxes have been taken.
private
static
double
CalculateTax3(
double
v)
{
throw
new
NotImplementedException();
}
static
double
CalculateTax3(
double
GrossIncome3,
double
NetIncomeTotal3)
{
return
GrossIncome3 - NetIncomeTotal3;
}
// For the calculations of the amount of taxes that have been taken out.
static
double
CalculateAnnualIncome3(
double
AnnualIncome3,
double
NetIncomeTotal3)
{
return
NetIncomeTotal3 * 12;
}
// For the calculations of what was made after taxes have been taken.
static
double
CalculateAnnualTax3(
double
TaxesWitheld3,
double
TaxesWithheldAnnual3)
{
return
TaxesWitheld3 * 12;
}
// For the calculations of the amount of taxes that have been taken out.
public
override
string
ToString()
{
return
base
.ToString();
}
public
override
bool
Equals(
object
obj)
{
return
base
.Equals(obj);
}
public
override
int
GetHashCode()
{
return
base
.GetHashCode();
}
}
}
Reply
Answers (
1
)
Error in selection Datetimepicker date
for gridview some row it does not redirect to next page