0% found this document useful (0 votes)
27 views2 pages

"Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday"

This document contains code for a parking fare calculator program. It defines arrays for days of the week, maximum hourly rates, and standard rates. It then contains a loop that prompts the user for inputs like day, arrival time, hours parked, and frequent parking number. Based on these inputs, it calculates the fare amount, applies any discounts, and keeps a running total of amounts collected.

Uploaded by

Adnan Saleem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views2 pages

"Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday"

This document contains code for a parking fare calculator program. It defines arrays for days of the week, maximum hourly rates, and standard rates. It then contains a loop that prompts the user for inputs like day, arrival time, hours parked, and frequent parking number. Based on these inputs, it calculates the fare amount, applies any discounts, and keeps a running total of amounts collected.

Uploaded by

Adnan Saleem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Module Module1

Sub Main()
Dim day() As String = {"Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"}
Dim maxstay1() As Integer = {8, 2, 2, 2, 2, 2, 4}
Dim maxstay2() As Integer = {2, 2, 2, 2, 2, 2, 2}
Dim rate1() As Integer = {2, 10, 10, 10, 10, 10, 3}
Dim rate2() As Integer = {2, 2, 2, 2, 2, 2, 2}

Dim dayno, arrival, hoursofstay, fare, fpn, digit, fpnsum, count As


Integer
Dim amount, daytotal As Integer
Dim ans As Boolean
daytotal = 0
Do
'validation for day number
Do
Console.Write("Enter day number 1:Sunday ....7:Saturday : ")
dayno = Console.ReadLine
Loop Until dayno >= 1 And dayno <= 7
'validation for arrival time
Do
Console.Write("Enter hour of arrival Time excluding minutes")
arrival = Int(Console.ReadLine())
Loop Until arrival >= 8 And arrival <= 24
'validation for hours of stay
Do
Console.Write("Hours of stay :")
hoursofstay = Console.ReadLine()
Loop Until hoursofstay + arrival <= 24
'calculation of fare task 1
If arrival <= 15 Then
fare = rate1(dayno - 1) * hoursofstay
Else
fare = rate2(dayno - 1) * hoursofstay
End If
'checking for valid frequent parking number
count = 1
fpn = 0
Do
Console.Write("Enter your five-digit frequent parking number
if available: ")
fpn = Console.ReadLine
Loop Until (fpn > 9999 And fpn <= 99999) Or fpn = 0
Do
digit = fpn Mod 10
fpnsum = fpnsum + (digit * count)
fpn = Int(fpn / 10)
count = count + 1
Loop Until fpn <= 0
If fpnsum Mod 11 = 0 And fpn <> 0 Then
If arrival >= 16 Then
Console.WriteLine("frequent parking number has correct
check digit, 50% discount applied.")
fare = fare * 0.5
Else
Console.WriteLine("frequent parking number has correct
check digit, 10% discount applied.")
fare = fare * 0.9
End If
Else
Console.WriteLine("Frequent Parking number is incorrect")
End If
Console.WriteLine("Fare Charged: " & fare)
Console.Write("Enter amount to paid : ")
amount = Console.ReadLine()
daytotal = daytotal + amount
Console.Write("Do you want to continue: ")
ans = Console.ReadLine()
Loop Until ans
Console.WriteLine("Total amount collected for the day = " & daytotal)
Console.ReadKey()
'calculation of fare task 3
If arrival + hoursofstay <= 15 Then
fare = rate1(dayno - 1) * hoursofstay
Else
fare = (rate2(dayno - 1) * (15 - arrival)) + 2
End If
End Sub

End Module

You might also like