Hi all,

I am a first year student at northeastern and my VB professor assigned me a project that i am just stuck on. This is my first programming course and i honestly am a newbie at it so i hope you guys can help. Here is my situation.

A parking garage charges a 10 minimum fee to park for up to three hours. the garage charges an addtional 3.25 per hour excess of three hours. the maximum charge for any given 24-hour period is 40.00. Parking validation from a merchant allos a 10% discount on the total charges. a parking pass provides parking for up to 12 hours at no charge with a charge of 3.25 for each addtional hour or part thereof. customers with a husky card get 5 hours free with the 3.25 per hour chagre for all remaining hours. Assume that no car parks for longer than 24 hours at a time. wrtie a program that will calculate and display the parking charges for each customer who parked his or her car in this arage. You should enter the hours parked for each customer along with their license plate number and state. If they are from NJ,CT or NY add an addtional 5.00 for an obnoxiia surcharge.

I have designed the GUI if anyone is up to take a look i can either email it to you or send it to you over Aim. Thanks again.

Dani AI

Generated

The code posted by (credited to comatose) has the right high-level structure but several practical and correctness issues that will give wrong results or runtime errors. Major points to fix: validate and convert input before using it, use explicit typed variables (prefer Currency for money), set the merchant discount to 10% (not 1%), implement "hour or part thereof" by rounding up, make state-surcharge checks robust, actually use the all-day cap constant, and avoid uninitialized temporaries.

Suggested, testable algorithm (implement these steps in the button click handler):

  1. Validate txtParked.Text with IsNumeric and ensure 0 <= hours <= 24.
  2. Convert to a numeric type (Double or Currency).
  3. Determine free time and base charge:
    • Regular customers: freeTime = 3, baseCharge = 10.
    • Parking pass: freeTime = 12, baseCharge = 0.
    • Husky card: add 5 to freeTime (or make pass/husky mutually exclusive via UI).
  4. chargeableHours = max(0, ceiling(hours - freeTime)). total = baseCharge + chargeableHours * feeRate.
  5. If state ∈ {NJ, CT, NY} add $5 surcharge (compare uppercase trimmed value or use a combobox).
  6. If merchant validation checked apply a 10% discount (total *= 0.9).
  7. Enforce the 24-hour cap: total = min(total, allDay). Format display with FormatCurrency(total,2).

VB-specific fixes and tips: add Option Explicit, declare Dim hours As Double and Dim total As Currency (avoids floating rounding), declare all temporaries, and initialize constants like allDay = 40 and mdiscount = 0.1. Validate text fields before conversion to avoid type errors.

A small VB6 helper to round up fractional hours (place in code after computing hoursLeft):

Dim raw As Double
Dim extraHours As Integer
raw = hoursLeft
extraHours = Int(raw)
If raw > extraHours Then extraHours = extraHours + 1

Recommended GUI adjustments (useful for and ): use a combobox for state to avoid typos, checkboxes for merchant/husky, and radio buttons for pass vs regular if they must be exclusive. Add a short table of test cases (e.g., 2.5h regular → $10; 3.1h regular → $13.25; 13h pass → $3.25; 24h → $40) and document whether the $40 cap is applied before or after the merchant discount so results stay predictable.

This coding was done by comatose he was awesome and extremely helpful in explaining and making a newbie like myself understand VB alittle more clearly. The comments were also done by comatose to help the user understand what he is actually doing step by step. Here is the complete program code. To make this project work.

' /* Declare Variables */
Dim hours
Dim total As Single
Dim mdiscount As Single
Dim pass As Integer
Dim card As Integer

Dim Plate As String
Dim fee As Integer
Dim feeRate As Single
Dim allDay As Integer
Dim FreeTime As Integer

Private Sub cmdExit_Click()
' /* This Code Unloads ALL THE FORMS in the project */
Dim XFrm
' /* For every Form in our project */
For Each XFrm In Forms
    ' /* Unload The Form */
    Unload XFrm
Next XFrm
End Sub

Private Sub cmdOK_Click()
' /* Get The Value In The TextBox, and Return It as An Integer */
hours = txtParked.Text
' /* Get The Plate Number */
Plate = txtPlates.Text

' /* Check If They Left The Hours Blank */
If hours = "" Then
    ' /* If So alert the User */
    MsgBox "Please Enter The Amount Of Time In The Parking Lot"
    ' /* Exit The Sub Routine */
    Exit Sub
End If

' /* Check If They Left The License Plate Box Blank */
If Plate = "" Then
    ' /* If So, Alert the User */
    MsgBox "Enter The License Plate"
    ' /* Exit This Sub */
    Exit Sub
End If
 
 If total >= 40 Then
    total = 40
End If

' /* If They Don't have a pass */
If chkPass.Value = 0 Then
    ' /* They Get Three Hours Without being charged additional Time fee */
    FreeTime = 3
    ' /* Set The Total They Owe To The Value Of Fee (10 bucks) */
    total = fee
' /* If They DO Have A Pass */
ElseIf chkPass.Value = 1 Then
    ' /* They Get 12 Hours Free */
    FreeTime = 12
    ' /* With No Charge */
    total = 0
End If

' /* If They Have A Husky Pass */
If chkHusky.Value = 1 Then
    ' /* Add 5 Hours To The Free Time They Get Before Additional 3.25 Charge */
    FreeTime = FreeTime + 5
End If

' /* Total Hours Will Be Hours Entered, Minus However much Time They Get Free */
hours = hours - FreeTime

' /* If Hours Is Less Than Or Equal To 0, They User Doesn't Owe Anything */
If hours <= 0 Then
    ' /* NO Charge */
    total = 0
Else
    ' /* Otherwise, They Owe Something */
    ' /* So, set tmp to hours remaining (after free time) times 3.25 (feeRate) */
    tmp = hours * feeRate
    ' /* Total Equals Total Ammount They Owe, PLUS The Value of Tmp (3.25 * whatever) */
    total = total + tmp
End If

' /* If They are From a Crappy state */
If OptState.Value = True Then
    ' /* Add 5 to what they owe */
    total = total + 5
End If

' /* If They Have A Merchant Pass */
If chkMerchant.Value = 1 Then
    ' /* Get 10 percent of the total */
    tmp = total * mdiscount
    ' /* Subtract whatever 10% of the total is, from the total */
    total = (total - tmp)
End If
If total >= 40 Then
    total = 40
End If

' /* Set The Label To The Total */
lblCharge.Caption = total

End Sub

Private Sub Form_Load()
fee = 10
feeRate = 3.25
allDay = 40
mdiscount = 0.01
End Sub

Hi! Simon, Im a student just like you
please send me your GUI coz im also stuck on how to design.
Help me Simon,
My email is <EMAIL SNIPPED>
Thanx

please help me simon i am a student i wnt to make project like you so please give me your project this is my e mail address <EMAIL SNIPPED>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.