Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Strict On
- Public Class Form1
- 'Program: Lab4jtgrkb
- 'Author: James Griffin, jtgtrkb, lab K
- 'Date 9/29/10
- 'description: program to read a choosen file of member information, determine
- 'membership level and cost for year, process current payment toward
- 'that yearly membership
- Private Sub btnprocess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnprocess.Click
- '0. Declare variables
- Dim sr As IO.StreamReader
- Dim filename, fullname As String
- Dim yearlyincome, previouspayment, memcost, fee As Double
- Dim newBalanceDue, previousBalance, currentpay As Double
- Dim day, memtype, first As String
- Dim positionpoint As Integer
- Dim clerkname As String
- Dim formatstring As String = "{0,-20} {1,20:C2}"
- '0 Clear listbox
- lstoutput.Items.Clear()
- '1. Obtain name, income, and previous payment from the approariate file.
- ' 1a. determine the filename based on the combox box selected
- Select Case cbofile.Text
- Case "Martin Wilson"
- filename = "Martin.txt"
- Case "Delmelza Connor"
- filename = "Delmelza.txt"
- Case "Alissa McKinnley"
- filename = "Alissa.txt"
- Case Else
- cbofile.Text = "Haines Corporation"
- filename = "Haines.txt"
- End Select
- ' 1b. open the file and read the first thre lines
- ' (full member name, member income, previous payment,date).
- sr = IO.File.OpenText(filename)
- fullname = sr.ReadLine
- yearlyincome = CDbl(Val(sr.ReadLine))
- previouspayment = CDbl(Val(sr.ReadLine))
- positionpoint = fullname.IndexOf(".")
- first = fullname.Substring(positionpoint + 1).Trim
- clerkname = txtclerk.Text
- day = mskdate.Text
- ' 1c. Close the file
- sr.Close()
- '2. Determine the membership type based on the radio button selected.(elseif)
- If radsingle.Checked Then
- fee = 50
- memtype = "Single"
- ElseIf radpartners.Checked Then
- fee = 75
- memtype = "Partners"
- ElseIf radfamily.Checked Then
- fee = 100
- memtype = "Family"
- ElseIf radcorporate.Checked Then
- fee = 500 + 8750
- memtype = "Corporate"
- End If
- '3. Get the current payment from the user via an input box.
- currentpay = CDbl(InputBox("Enter Current Payment", "Payment", "100"))
- '4. Calculate the member cost based on the income.(use chart)
- ' 4a. Member cost for non-corporate members is based on chart in the lab 4 assignment
- Select Case yearlyincome
- Case Is > 246750
- memcost = 3660 + 0.03 * (yearlyincome - 246750)
- Case Is > 100350
- memcost = 1226 + 0.025 * (yearlyincome - 100350)
- Case Is > 39050
- memcost = 328.5 + 0.02 * (yearlyincome - 39050)
- Case Is > 17150
- memcost = 171.5 + 0.015 * (yearlyincome - 17150)
- Case Else
- memcost = yearlyincome * 0.01
- End Select
- ' 4b. Member cost for corporate member is 8750.
- '5 add category fee to membership cost
- memcost = memcost + fee
- '6. Do calculations (amount due, previous balance, yearly fees).
- previousBalance = memcost - previouspayment
- newBalanceDue = previousBalance - currentpay
- '7. Show all this stuff.(print)
- lstoutput.Items.Add(String.Format(formatstring, "Clerk Name", clerkname))
- lstoutput.Items.Add(String.Format(formatstring, "Date", day))
- lstoutput.Items.Add(String.Format(formatstring, "___________", "______________"))
- lstoutput.Items.Add(String.Format(formatstring, "Member:", first))
- lstoutput.Items.Add(String.Format(formatstring, "Membership Type", memtype))
- lstoutput.Items.Add(String.Format(formatstring, "Yearly Fees", memcost))
- lstoutput.Items.Add(String.Format(formatstring, "Previous Payment", previouspayment))
- lstoutput.Items.Add(String.Format(formatstring, " ", " ------------ "))
- lstoutput.Items.Add(String.Format(formatstring, "Previous Balance", previousBalance))
- lstoutput.Items.Add(String.Format(formatstring, "Current Payment", currentpay))
- lstoutput.Items.Add(String.Format(formatstring, " ", " ------------ "))
- lstoutput.Items.Add(String.Format(formatstring, "New Balance Due", newBalanceDue))
- End Sub
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- radcorporate.Checked = True
- cbofile.Text = "Haines Corporation"
- End Sub
- Private Sub btnexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnexit.Click
- End
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement