This code calculates taxi fares based on passenger type (regular or student) and kilometers traveled. It takes the passenger type and kilometers as input, calculates the total amount due, and displays it. If a regular passenger travels 1-4 km the fare is 8; if a student travels 1-4 km the fare is 7. For distances over 4 km, it calculates the amount due based on a rate of 1 per km for regular passengers or 0.8 per km for students, plus the base fare.
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 ratings0% found this document useful (0 votes)
51 views1 page
Windows Application 7
This code calculates taxi fares based on passenger type (regular or student) and kilometers traveled. It takes the passenger type and kilometers as input, calculates the total amount due, and displays it. If a regular passenger travels 1-4 km the fare is 8; if a student travels 1-4 km the fare is 7. For distances over 4 km, it calculates the amount due based on a rate of 1 per km for regular passengers or 0.8 per km for students, plus the base fare.
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/ 1
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click Dim PassengerType As Char Dim Kilometer As Double Dim TotalAmount As Double PassengerType = TextBox1.Text Kilometer = Val(TextBox2.Text) TextBox3.Text = TotalAmount If PassengerType = "R" And Kilometer >= 1 And Kilometer <= 4 Then TextBox3.Text = 8 ElseIf PassengerType = "S" And Kilometer >= 1 And Kilometer <= 4 Then TextBox3.Text = 7 ElseIf PassengerType = "S" And Kilometer > 4 Then TextBox3.Text = ((Kilometer - 4) * 0.8 + 7) ElseIf PassengerType = "R" And Kilometer > 4 Then TextBox3.Text = ((Kilometer - 4) * 1 + 8) End If End Sub End Class