1) Pennies for Pay You are hired for a job and your employer agrees to pay you each day. Your pay rate will be one penny the first day and two pennies the second day, four pennies the third day and continuing to double each day. Create an application the will calculate your total pay for the number of days worked. Number of days worked can be from 1 to 30 days.
User inputs: Number of days worked. Output: Total Pay Earned

 

 

 

 

 


'Compiler Directives
Option Explicit On
Option Strict On

Public Class frmFinalExam

'Calculate the Number of Days worked and Total Pay Earned
Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click

Dim dblamount As Double = 0
Dim dblTotalPay As Double = 0
Dim dblAmountInDollar As Double = 0
Dim dblNumberofDays As Double = 0


Double.TryParse(txtDays.Text, dblNumberofDays)

' loop for the specified number of days:

If (dblNumberofDays <= 0) Then
MessageBox.Show("Days Must Be greater than 0")
End If


For d As Double = 1 To dblNumberofDays
If d <= 0 Then
MessageBox.Show("Please enter a valid number of days.", "Days Must be between 1 and 30.", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else

End If
If d >= 30 Then
MessageBox.Show("Please enter a valid number of days.", "Days Must be between 1 and 30.", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else

End If
If d = 1 Then
dblamount = 0.01
Else

End If
If d = dblamount Then
dblamount = dblNumberofDays * 0.01 ^ 2 + dblTotalPay

End If
dblTotalPay = dblTotalPay + dblamount

Next
lblTotal.Text = dblTotalPay.ToString("C")
End Sub

'To Exit out of the program
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Dim intAnswer As Integer
intAnswer = MessageBox.Show("Do you want to Exit?", "Exit request", MessageBoxButtons.YesNo)
Debug.Print("Answer=" & intAnswer)
If (intAnswer = vbYes) Then
Me.Close()
End If
End Sub

Private Sub txtDays_TextChanged(sender As Object, e As EventArgs) Handles txtDays.TextChanged
lblTotal.Text = ""
End Sub



End Class

    • 11 years ago
    Complete A++ Solution
    NOT RATED

    Purchase the answer to view it

    • cis_130_final_exam_lab.zip