Work 12: 10/4

posted Oct 4, 2018, 10:33 AM by JonAlf Dyrland-Weaver   [ updated Oct 4, 2018, 11:44 AM ]
Write the following functions in racket:

  • div3?
    • Takes one number
      • Returns true if the argument is divisible by 3, false otherwise.
      • Examples:
        • (div3 12) ==> #t
        • (div3 8) ==> #f
  • taxiFare
    • A taxi company charges it's users based on how many other people need taxis at the same time in the same area. 
    • If there are fewer that 5 people in the same area, then the company charges $1.50 per mile.
    • If there are 5 or more people in the same area, then the company charges $2.50 per mile.
    • Write a function that takes two parameters, the first represents the number of miles needed to go and the second represents the number of other customers nearby. 
    • The function should return the total cost of the trip.
    • Examples
      • (taxiFare 8 3) ==> 12.0
      • (taxifare 8 6) ==> 20.0
  • alarmTime 
    • Takes two arguments, the first is a # representing the day of the week (0=Sun, 1=Mon, 2=Tue, ...6=Sat), the other is a boolean value representing whether it is a vacation day.
    • Returns when the alarm clock should ring on the given day based on these rules:
    • Weekdays, the alarm should be 6
    • Weekend it should be 10 
    • Unless we are on vacation
      • Weekdays should be 10
      • Weekends should be 12.
  • letterGrade
    • Takes a positive number representing a grade.
    • Returns a letter for the grade based on the following rules
      • "E": grade >= 90 
      • "S": 90 > grade >= 75
      • "N": 75 > grade >= 65
      • "U": 65 > grade
Submit these functions as test1-review

Comments