Khalid A.

asked • 11/04/14

Programming questions

this question is stressing me out i cant even know what to start. it is in Visual Basic. Design a program that calculates and displays the number of miles per hour over the speed limit that a speeding driver was doing. The program should ask for the speed limit and the driver's speed. Validate the input as follows:
-The speed limit should be at lease 20, but not greater than 70.
-The driver's speed should be at least the value entered for the speed limit (otherwise the driver was not speeding).

Once correct data has been entered, the program should calculate and display the number of miles per hour over the speed limit that the driver was doing.

Anthony F.

Display "Please, input speed limit"
Display "Please, input car speed"....
 
 
 
Report

11/02/15

Anthony F.

Module Module1
    Sub Main()
        Console.WriteLine("Please enter speed limit when it's between 19 and 71 mph and press enter")
        Dim speedlimit As Integer
        speedlimit=Console.ReadLine()
        Console.WriteLine("You entered:" & speedlimit)
        If speedlimit < 20 then
          ConsoleWriteLine("Speed limit must be at least 20 mph")
          ConsoleReadLine()
        End If
        If speedlimit > 70 then
           ConsoleWriteLine("Speed limit over 70 mph")
           ConsoleReadLine()
        End If
                                                                                .
                                                                                .
                                                                                .
                                                                                .
   End Sub
End Module
 
The following website is Visual Basic coding: https://mva.microsoft.com/en-US/training-courses/vb-fundamentals-for-absolute-beginners-8297?|=O9LQsNYy_3004984382
Report

11/02/15

Anthony F.

Below is Visual Basic code.
 
Module Module1
    Sub Main()
      Dim valid_speed_limit As String
      valid_speed_limit = "yes"
      While valid_speed_limit = "yes"
        Console.WriteLine("Please enter speed limit, if it's between 19 
                                    and 71 mph, then press enter")
        Dim speed_limit As Integer
        speed_limit = Console.ReadLine()
        Console.WriteLine("You entered:" & speed_limit)
        Console.ReadLine()
        Dim message as String = " "
        If speed_limit < 20 Then
          message = "Sorry, speed limit less than 20 mph. Try again "
        ElseIf speed_limit > 70 Then
          message = "Sorry, speed limit more than 70 mph.Try again."
        Else valid_speed_limit = "no"
        End If
        Console.WriteLine(message)
        Console.ReadLine()
   End While 
   Console.WriteLine("Please enter the car's speed then press enter")
   Dim car_speed As Integer
   car_speed = Console.ReadLine()
   Console.WriteLine("You entered:" & car_speed)
   Console ReadLine()
   If car_speed > valid_speed_limit Then
     message = "Alert! You are driving over the speed limit"
   Else message = "You are driving at or under the speed limit."
   EndIf
   Console.WriteLine(message)
   Console.ReadLine()
  End Sub
End Module
Report

11/03/15

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.