Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' Name: calcMembership
- ' Purpose: Calculate and total the membership fees for club members
- ' Author: Tim Whitfort
- Module Module1
- ' Global variable declarations. These variables can be used throughout the program
- Dim membershipFee As Double
- Dim membershipType As String
- ' The main subroutine. This is to be executed first
- Sub Main()
- ' Local variable declaration. This variable can be used in this subroutine only
- Dim totalFees As Double
- totalFees = 0
- ' Call the inputMembershipType subroutine
- inputMembershipType()
- While membershipType <> "X"
- ' Call the calcMembershipFee subroutine
- calcMembershipFee()
- ' Total the fees so far
- totalFees = totalFees + membershipFee
- ' Display the membership fee for the member
- Console.WriteLine("Membership fee = " & membershipFee)
- ' Call the inputMembershipType subroutine
- inputMembershipType()
- End While
- ' Display the total fees for members input
- Console.WriteLine("Total fees = " & totalFees)
- Console.ReadLine()
- End Sub
- ' Input and validate a membership type
- Sub inputMembershipType()
- Console.Write("Membership type (F=Full, J=Junior, L=Life, X=eXit) ? ")
- membershipType = Console.ReadLine()
- While membershipType <> "F" And membershipType <> "J" And _
- membershipType <> "L" And membershipType <> "X"
- Console.WriteLine("Error: membership type must be F, J, L or X")
- Console.Write("Membership type (F=Full, J=Junior, L=Life, X=eXit) ? ")
- membershipType = Console.ReadLine()
- End While
- End Sub
- ' Determine the membership fee based on the membership type
- Sub calcMembershipFee()
- If membershipType = "F" Then
- membershipFee = 160
- Else
- If membershipType = "J" Then
- membershipFee = 80
- Else
- membershipFee = 10
- End If
- End If
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement