Exercises in Visual Basic
Exercises in Visual Basic
A travel agency must prepare a draft catalog with N special trips. For each trip, the following is known:
destination
able to fulfill the following requests:
Load and display the data in appropriate listboxes
2.Enter the amount you have available to spend, display the destinations that have a cost.
less than or equal to (search with for loop)
3. Enter a destination via the keyboard, display the cost and the number of available seats, sending a message.
if it is not present in the list (search with found)
4. Order the trips by destination in alphabetical order and display the resulting list with associated costs.
the available spots in the listboxes.
Exercise 2
A small provincial town has equipped itself with some speed detectors and wishes to automate certain operations.
Two parallel vectors containing the license plate number and the recorded speed of the vehicle should be provided as input.
These data refer to N vehicles circulating on a stretch of road in the municipality, on a specific day. Write a
program that, given N as input, after loading and displaying the vectors in two listboxes, allows to manage the following
requests:
1. Count: to count and show how many vehicles have exceeded the speed limit provided as input
2. Violations: display the vehicle's license plate with maximum speed
3. License-vehicles: given the license plate of a vehicle, display its speed, sending a message if it is not found.
Exercise 3
The products treated in an herbalist's shop are stored in two parallel arrays: name of the medicine, selling price.
After loading the N products into the vectors, write a program that allows managing the following requests:
1. Name-minimum price: sort the vectors (bubble sort) while maintaining data parallelism, then show the
name of the medicine with the lowest price
2. Economical: count and display how many medicines have a price lower than a given input amount.
3. Product-class: given the name of a product, display its price, sending a message if the product does not
it is located
4. Media: calculate and display the price of medications.
Exercise 4
Given 3 vectors with children's names from a school, age, and gender.
The name of the child up to age
2. The average age of females
3.Sort the vectors based on the age of the children (from oldest to youngest)
4. Given a child's name, display their age and gender, sending a message if the name is not found.
Public ClassForm1
Dim N As Integer
Dimi As Integer
DimImp As Integer
DimD(50) As String
DimP(50) As Integer
DimC(50) As Integer
DimTrovatoAs Boolean
DimKey As String
Private Sub BtnCarica_Click(sender As Object, e As EventArgs) Handles BtnCarica.Click
TxtN.Text
For i = 0 to N - 1
D(i) = InputBox("Enter the destination of the " + Str(i + 1) + "th trip",
Destination
P(i) = Val(InputBox("How many available seats are there for " + D(i) + "?", "Seats
available
C(i) = Val(InputBox("How much does the trip to " + D(i) + " cost?", "Cost of the trip"))
ListaD.Items.Add(D(i))
ListaP.Items.Add(P(i))
ListaC.Items.Add(C(i))
Next
End Sub