What I have here is a small console app I'm wanting the user to type in their monthly salary then their "Expenses" To calculate how much money they have over the month once they take away their expenses (A calculator that tells the user how much money they have monthly once all bills are paid). I'd like to take away from int Salary. I want the expenses to keep populating until the user types "false", in the bool FinishedAdding currently the variable Expenses only holds one value, I want to add all Expenses then subtract from Salary. Am I doing this correctly or is this the wrong approach?
string NewLine = "\n";
bool Finished = false;
var Expenses = default(int);
Console.WriteLine("Enter you earn a month (after tax");
int Salary = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(NewLine);
if (Finished != true)
{
while (Finished == false)
{
Console.WriteLine("What are your expenses");
Expenses = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("You are finished?");
bool FinishedAdding = Convert.ToBoolean(Console.ReadLine());
if (FinishedAdding == true)
{
break;
}
}
}
Console.WriteLine(NewLine);
Console.WriteLine("Your total is: " + (Expenses - Salary));
if( Finished != true ). If it is false, the while won't be entered. 2.) You want to subtract Expenses from Salary, why do you then subtract Salary from Expenses? ...