Car speed

Report a typo

Create a program that checks whether a car exceeds a speed limit.

Write a function checkSpeed() that will take two arguments: speed and limit. By default the limit is 60 kilometers per hour.

The speed contains the actual speed of the car. The limit contains the limit on the road. If there is no special restriction, you must apply the default limit.

Output Exceeds the limit by N kilometers per hour where N is kilometers per hour above the limit. If everything's OK, output Within the limit.

Sample Input 1:

100
60

Sample Output 1:

Exceeds the limit by 40 kilometers per hour

Sample Input 2:

40
90

Sample Output 2:

Within the limit

Sample Input 3:

61
no limit

Sample Output 3:

Exceeds the limit by 1 kilometers per hour

Sample Input 4:

60
no limit

Sample Output 4:

Within the limit
Write a program in Kotlin
fun checkSpeed(...) {
// write your code here
}
___

Create a free account to access the full topic