A program using loops that outputs each step to a label...
Posted on 2004-11-09
I'm new to programming and stuck on something...using VB.net and loops how would you make a program that can calculate how much money one would have at the end of 30 days if they got paid one penny on the first day, and double each subsequent day...day two .02, day 3 .04 etc...?
And how do you make it print each step that it does on a single line...like a line for day one, a line for day two, etc, that says DAY, TOTAL PAID, and TOTAL SALARY FOR THE MONTH SO FAR?
This is what I have so far...
Private Sub btnCalculate_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles btnCalculate.Click
' calculate and display the salary for each day and the total for each day
Dim TotalSalary As Single
Dim OneDaysPay As Single
Dim DayCount As Integer
' display headings in output label
lblOutput.Text = "Day Pay Total" & vbNewLine
' Initialize total
TotalSalary = 0.01
' start with 1 cent on the first day
OneDaysPay = 0.01 ' start with one cent the first day
' Write a loop that proceeds for 30 days, displaying the day's
' pay and the total so far, then doubling the day's pay
' After the loop, tell programmer which pay rate to take
DayCount = 1
For DayCount = 1 To 30
TotalSalary = OneDaysPay * 2
Me.lblOutput.Text = TotalSalary