String handling operations in a programming language

EasyMedium
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
Question 7
Easy

An algorithm is written in VB.Net to validate a flight booking reference and calculate any cabin-class baggage surcharge.

Figure 1

1  Dim extraCharge As Decimal = 0.0
2  Console.Write("Enter booking reference: ")
3  Dim bookingRef As String = Console.ReadLine()
4  While bookingRef.Length() < 8
5      Dim warningText As String = " is too short for a standard reference"
6      Console.WriteLine(warningText)
7      bookingRef = Console.ReadLine()
8  End While
9  Console.Write("Enter cabin class (1 for First, 2 for Economy): ")
10 Dim cabinClass As Integer = Console.ReadLine()
11 If cabinClass = 1 Then
12     extraCharge = 0.0
13 Else
14     extraCharge = 25.0
15 End If
16 Console.WriteLine(extraCharge)

Rewrite line 5 in Figure 1 to concatenate the booking reference string stored in the variable bookingRef with the string " is too short for a standard reference", and store the result in the variable warningText.

Your answer must be written in VB.Net.

[1]

String handling operations in a programming language Questions

  1. GCSE
  2. /Computer Science
  3. /String handling operations in a programming language