Alexa White

Alexa White

  • NA
  • 2
  • 481

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:
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Text;  
  4. using System.Threading.Tasks;  
  5. using System.Linq;  
  6. using System.Threading;  
  7. namespace MonthlyTaxCalculator3  
  8. {  
  9. class Program  
  10. {  
  11. static void Main(string[] args)  
  12. {  
  13. const double Tax_Rate = 0.07;  
  14. // The percentage of tax, 7%, that is taken from Employee's monthly gross income.  
  15. Console.WriteLine("______________________________________________");  
  16. // Title and Header  
  17. Console.WriteLine(" Monthly Gross Income Tax Calculator: employee Name #1 ");  
  18. Console.WriteLine("______________________________________________");  
  19. // Title and Header  
  20. Console.Write("\n Welcome Software Developers! Please enter the first name: ");  
  21. string employeeName1 = Console.ReadLine();  
  22. // For obtianing the Software Developer's name.  
  23. Console.Write("\n Please enter your address listed on file: ");  
  24. string employeeAddress1 = Console.ReadLine();  
  25. // For obtaining the Software Developer's address that is listed on their employee file.  
  26. Console.Write("\n To calculate the 7% tax paid each month, please enter your annual monthly gross income: ");  
  27. double grossIncome1 = Convert.ToDouble(Console.ReadLine());  
  28. // For calculating the 7% tax paid from each of the Software Developer's annual monthly gross income.  
  29. Console.Write("\n What income type are you on a W2 or subcontractor: ");  
  30. bool incomeType1 = Convert.ToBoolean(Console.ReadLine());  
  31. // For obtaining the Software Developers income type  
  32. bool[] incomeType = {truefalse};  
  33. bool W2 = true;  
  34. W2 = incomeType1;  
  35. bool subcontractor = false;  
  36. subcontractor = incomeType1;  
  37. if (incomeType1 == W2)  
  38. {  
  39. double netIncomeTotal1 = CalculateGrossIncome1(grossIncome1, Tax_Rate);  
  40. double taxesWithheld1 = CalculateTax1(grossIncome1, netIncomeTotal1);  
  41. double netAnnualIncomeTotal1 = CalculateAnnualIncome1(grossIncome1, 12);  
  42. double taxesWithheldAnnual1 = CalculateAnnualTax1(taxesWithheld1, 12);  
  43. // For calculating the 7% tax rate from the annual monthly gross income, and the amount of tax and amount of income left.  
  44. Console.WriteLine("\n\n Here is the annual monthly gross tax information summary: ", employeeName1);  
  45. Console.WriteLine("\n Monthly Gross Income Before Taxes: {0:C2}", grossIncome1);  
  46. Console.WriteLine(" Total Monthly Gross Income After Taxes Withheld: {0:C2}", taxesWithheld1);  
  47. Console.WriteLine(" Monthly Net Income Taxes: {0:C2}", netIncomeTotal1);  
  48. Console.WriteLine("\n Annual Yearly Gross Income Before Taxes: {0:C2}", netAnnualIncomeTotal1);  
  49. Console.WriteLine(" Total Annual Yearly Gross Income After Taxes Withheld: {0:C2}", taxesWithheldAnnual1);  
  50. }  
  51. else  
  52. {  
  53. double netAnnualIncomeTotal1 = CalculateAnnualIncome1(grossIncome1, 12);  
  54. Console.WriteLine("\n\n Here is the annual monthly gross tax information summary: ", employeeName1, employeeAddress1);  
  55. Console.WriteLine("\n Annual Yearly Gross Income Before Taxes: {0:C2}", netAnnualIncomeTotal1);  
  56. }  
  57. Console.ReadLine();  
  58. Console.ReadKey(); //  
  59. Console.WriteLine("______________________________________________");  
  60. // Title and Header  
  61. Console.WriteLine(" Monthly Gross Income Tax Calculator: employee Name #2 ");  
  62. Console.WriteLine("______________________________________________");  
  63. // Title and Header  
  64. Console.Write("\n Welcome Software Developers! Please enter the second name: ");  
  65. string employeeName2 = Console.ReadLine();  
  66. // For obtianing the Software Developer's name.  
  67. Console.Write("\n Please enter your address listed on file: ");  
  68. string employeeAddress2 = Console.ReadLine();  
  69. // For obtaining the Software Developer's address that is listed on their employee file.  
  70. Console.Write("\n To calculate the 7% tax paid each month, please enter your annual monthly gross income: ");  
  71. double grossIncome2 = Convert.ToDouble(Console.ReadLine());  
  72. // For calculating the 7% tax paid from each of the Software Developer's annual monthly gross income.  
  73. double netIncomeTotal2 = CalculateGrossIncome2(grossIncome2, Tax_Rate);  
  74. double taxesWithheld2 = CalculateTax2(grossIncome2, netIncomeTotal2);  
  75. double netAnnualIncomeTotal2 = CalculateAnnualIncome2(grossIncome2, 12);  
  76. double taxesWithheldAnnual2 = CalculateAnnualTax2(taxesWithheld2, 12);  
  77. // For calculating the 7% tax rate from the annual monthly gross income, and the amount of tax and amount of income left.  
  78. Console.WriteLine("\n\n Here is the annual monthly gross tax information summary: ", employeeName2);  
  79. Console.WriteLine("\n Monthly Gross Income Before Taxes: {0:C2}", grossIncome2);  
  80. Console.WriteLine(" Total Monthly Gross Income After Taxes Withheld: {0:C2}", taxesWithheld2);  
  81. Console.WriteLine(" Monthly Net Income Taxes: {0:C2}", netIncomeTotal2);  
  82. Console.WriteLine("\n Annual Yearly Gross Income Before Taxes: {0:C2}", netAnnualIncomeTotal2);  
  83. Console.WriteLine(" Total Annual Yearly Gross Income After Taxes Withheld: {0:C2}", taxesWithheldAnnual2);  
  84. Console.ReadLine(); //  
  85. Console.WriteLine("______________________________________________");  
  86. // Title and Header  
  87. Console.WriteLine(" Monthly Gross Income Tax Calculator: employee Name #3 ");  
  88. Console.WriteLine("______________________________________________");  
  89. // Title and Header  
  90. Console.Write("\n Welcome Software Developers! Please enter the third name: ");  
  91. string employeeName3 = Console.ReadLine();  
  92. // For obtianing the Software Developer's name.  
  93. Console.Write("\n Please enter your address listed on file: ");  
  94. string employeeAddress3 = Console.ReadLine();  
  95. // For obtaining the Software Developer's address that is listed on their employee file.  
  96. Console.Write("\n To calculate the 7% tax paid each month, please enter your annual monthly gross income: ");  
  97. double grossIncome3 = Convert.ToDouble(Console.ReadLine());  
  98. // For calculating the 7% tax paid from each of the Software Developer's annual monthly gross income.  
  99. Console.WriteLine("______________________________________________");  
  100. // Title and Header  
  101. double netIncomeTotal3 = CalculateGrossIncome3(grossIncome3, Tax_Rate);  
  102. double taxesWithheld3 = CalculateTax3(grossIncome3, netIncomeTotal3);  
  103. double netAnnualIncomeTotal3 = CalculateAnnualIncome3(grossIncome3, 12);  
  104. double taxesWithheldAnnual3 = CalculateAnnualTax3(taxesWithheld3, 12);  
  105. // For calculating the 7% tax rate from the annual monthly gross income, and the amount of tax and amount of income left.  
  106. Console.WriteLine("\n\n Here is the annual monthly gross tax information summary: ", employeeName3);  
  107. Console.WriteLine("\n Monthly Gross Income Before Taxes: {0:C2}", grossIncome3);  
  108. Console.WriteLine(" Total Monthly Gross Income After Taxes Withheld: {0:C2}", taxesWithheld3);  
  109. Console.WriteLine(" Monthly Net Income Taxes: {0:C2}", netIncomeTotal3);  
  110. Console.WriteLine("\n Annual Yearly Gross Income Before Taxes: {0:C2}", netAnnualIncomeTotal3);  
  111. Console.WriteLine(" Total Annual Yearly Gross Income After Taxes Withheld: {0:C2}", taxesWithheldAnnual3);  
  112. Console.ReadLine(); //  
  113. }  
  114. static bool incomeType1(double v)  
  115. {  
  116. throw new FormatException();  
  117. }  
  118. private static double CalculateGrossIncome1(double v)  
  119. {  
  120. throw new NotImplementedException();  
  121. }  
  122. static double CalculateGrossIncome1(double GrossIncome1, double Tax_Rate)  
  123. {  
  124. return GrossIncome1 * Tax_Rate;  
  125. }  
  126. // For the calculations of what was made after taxes have been taken.  
  127. private static double CalculateTax1(double v)  
  128. {  
  129. throw new NotImplementedException();  
  130. }  
  131. static double CalculateTax1(double GrossIncome1, double NetIncomeTotal1)  
  132. {  
  133. return GrossIncome1 - NetIncomeTotal1;  
  134. // For the calculations of the amount of taxes that have been taken out.  
  135. static double CalculateAnnualIncome1(double NetIncomeTotal1, double AnnualIncome1)  
  136. {  
  137. return NetIncomeTotal1 * 12;  
  138. }  
  139. // For the calculations of what was made after taxes have been taken.  
  140. static double CalculateAnnualTax1(double TaxesWithheld1, double TaxesWithheldAnnual1)  
  141. {  
  142. return TaxesWithheld1 * 12;  
  143. // For the calculations of the amount of taxes that have been taken out.  
  144. private static double CalculateGrossIncome2(double v)  
  145. {  
  146. throw new NotImplementedException();  
  147. }  
  148. static double CalculateGrossIncome2(double GrossIncome2, double Tax_Rate)  
  149. {  
  150. return GrossIncome2 * Tax_Rate;  
  151. }  
  152. // For the calculations of what was made after taxes have been taken.  
  153. private static double CalculateTax2(double v)  
  154. {  
  155. throw new NotImplementedException();  
  156. }  
  157. static double CalculateTax2(double GrossIncome2, double NetIncomeTotal2)  
  158. {  
  159. return GrossIncome2 - NetIncomeTotal2;  
  160. // For the calculations of the amount of taxes that have been taken out.  
  161. static double CalculateAnnualIncome2(double NetIncomeTotal2, double AnnualIncome2)  
  162. {  
  163. return NetIncomeTotal2 * 12;  
  164. }  
  165. // For the calculations of what was made after taxes have been taken.  
  166. static double CalculateAnnualTax2(double TaxesWithheldAnnual2, double TaxesWithheld2)  
  167. {  
  168. return TaxesWithheld2 * 12;  
  169. // For the calculations of the amount of taxes that have been taken out.  
  170. private static double CalculateGrossIncome3(double v)  
  171. {  
  172. throw new NotImplementedException();  
  173. }  
  174. static double CalculateGrossIncome3(double GrossIncome3, double Tax_Rate)  
  175. {  
  176. return GrossIncome3 * Tax_Rate;  
  177. }  
  178. // For the calculations of what was made after taxes have been taken.  
  179. private static double CalculateTax3(double v)  
  180. {  
  181. throw new NotImplementedException();  
  182. }  
  183. static double CalculateTax3(double GrossIncome3, double NetIncomeTotal3)  
  184. {  
  185. return GrossIncome3 - NetIncomeTotal3;  
  186. // For the calculations of the amount of taxes that have been taken out.  
  187. static double CalculateAnnualIncome3(double AnnualIncome3, double NetIncomeTotal3)  
  188. {  
  189. return NetIncomeTotal3 * 12;  
  190. }  
  191. // For the calculations of what was made after taxes have been taken.  
  192. static double CalculateAnnualTax3(double TaxesWitheld3, double TaxesWithheldAnnual3)  
  193. {  
  194. return TaxesWitheld3 * 12;  
  195. // For the calculations of the amount of taxes that have been taken out.  
  196. public override string ToString()  
  197. {  
  198. return base.ToString();  
  199. }  
  200. public override bool Equals(object obj)  
  201. {  
  202. return base.Equals(obj);  
  203. }  
  204. public override int GetHashCode()  
  205. {  
  206. return base.GetHashCode();  
  207. }  
  208. }  
  209. }

Answers (1)