static ProgramOutputs calculate(ProgramInputs inputs) { ProgramOutputs outputs = new ProgramOutputs(); outputs.MonthlyTotal = inputs.LoanPayment + inputs.Insurance + inputs.Gas + inputs.Oil + inputs.Tires + inputs.Maintenance; outputs.AnnualTotal = outputs.MonthlyTotal * 12; return(outputs); }
static void Main(string[] args) { Console.WriteLine("Please enter the following expenses on a per month basis"); ProgramInputs inputs = getInputs(); ProgramOutputs outputs = calculate(inputs); Console.WriteLine("Your monthly total is ${0:F2} and your annual total is ${1:F2}", outputs.MonthlyTotal, outputs.AnnualTotal); }
static ProgramInputs getInputs() { // make a new program input object ProgramInputs inputs = new ProgramInputs(); // get each input using a convenient method that factors out the parsing logic inputs.LoanPayment = getSingleInput("How much is the loan payment?"); inputs.Insurance = getSingleInput("How much is the insurance?"); inputs.Gas = getSingleInput("How much is the gas?"); inputs.Oil = getSingleInput("How much is the oil?"); inputs.Tires = getSingleInput("How much are the tires?"); inputs.Maintenance = getSingleInput("How much is the maintenance?"); // return them in single object, it's neater this way return(inputs); }