I'm very beginner when it comes to programming c#, there's two variables in a formula which aren't parsing as integers although i declared them within the main function. I have multiple methods achieving small tasks and it doesn't seem to be linking the main variable to the method one, the rest of the code doesn't have any errors so i'm not sure why it's not doing the formula. (I'll have to post all the code in order to show u)
public static void Main()
{
int income = 0;
int children = 0;
int tax = 0;
AskForIncome(income);
NoChild(children);
CalculateTax(tax);
ExitProgram();
}
public static void AskForIncome(int income)
{
Console.WriteLine("What is your total income: ");
string testNum = Console.ReadLine();
bool dummyBool = int.TryParse(testNum, out income);
if (dummyBool)
{
Console.WriteLine();
}
else if(income < 0)
{
Console.WriteLine("Your income cannot be negative.");
}
else
{
Console.WriteLine("Enter your income as a whole-dollar numeric figure.");
}
}
public static void NoChild(int children)
{
Console.WriteLine("How many children do you have: ");
string testChild = Console.ReadLine();
bool dummyBool2 = int.TryParse(testChild, out children);
if (dummyBool2)
{
Console.WriteLine();
}
else if(children < 0)
{
Console.WriteLine("You must enter a positive number.");
}
else
{
Console.WriteLine("You must enter a valid number.");
}
}
public static void CalculateTax(int tax)
{
tax = income - 10000 - (children * 2000);
if (tax < 0)
{
Console.WriteLine("You owe no tax.");
}
else
{
Console.WriteLine("You owe a total of $" + tax + " tax.");
}
}