# Pt1420 Assignment Essay

1063 Words5 Pages
Short Answer 1) Why should you indent the statements in the body of a loop? Because by indenting the statements in the body of the loop you visually set them apart from the surrounding code. This makes your program easier to read and debug 2) Describe the difference between pretest loops and posttest loops A pretest loop means to test its condition before performing an iteration A posttest loop means it performs an iteration before testing its condition 3) What is a condition-controlled loop? A condition-controlled loop uses a true/false condition to control the number of times that it repeats 4) What is a count-controlled loop? A count-controlled loop repeats a specific number of times 5) What three actions do…show more content…
le1 Sub Main() 'This program gets a budget for the user then display the amount the user is over or under budget Dim monthlyTotal As Double = 0 Dim budgetAmount As Double = 0 Dim sumAmount As Double = 0 'Getting the budget amount Console.WriteLine("What is your budget buddy?") budgetAmount = Console.ReadLine() Console.WriteLine("Your budget is " &amp; budgetAmount) Console.ReadLine() 'This function gets all the expense for the month getMonthlyExpenses(monthlyTotal) 'This module tells the user if they are over or under and by how much calculatingTotals(monthlyTotal, budgetAmount, sumAmount) Console.WriteLine("Press enter to continue") Console.ReadLine() End Sub Function getMonthlyExpenses(ByRef monthlyTotal As Double) Dim anymore As String = "Y" Dim expense As Double = 0 Do While anymore = UCase("Y") Console.WriteLine("Enter your expenses") expense = Console.ReadLine() monthlyTotal = monthlyTotal + expense Console.WriteLine(" Do you have anymore expenses enter y for Yes and n for NO?") anymore = Console.ReadLine() Loop Return monthlyTotal End Function Sub calculatingTotals(ByRef monthlyTotal As Double, ByRef budgetAmount As Double, ByRef sumAmount As Double) If budgetAmount &lt;