Menu
Coddy logo textTech

Recap - Simple Decisions

Part of the Fundamentals section of Coddy's Dart journey — lesson 34 of 94.

challenge icon

Challenge

Medium

Create a program that analyzes a person's eligibility for different types of driver's licenses based on their age and experience:

  1. Declare an integer variable age with a value of 19
  2. Declare an integer variable drivingExperience with a value of 2 (representing years)
  3. Declare a boolean variable hasPassedTest with a value of true
  4. Implement the following license eligibility rules:
    • If the person is under 16, print: Status: Not eligible for any driving license. Must be at least 16 years old.
    • If the person is 16 or 17:
      • If they passed the test, print: Status: Eligible for a provisional license.
      • If they haven't passed the test, print: Status: Not eligible yet. Need to pass the driving test.
    • If the person is 18 or older:
      • If they have less than 1 year of driving experience, print: Status: Eligible for a beginner license.
      • If they have 1-3 years of driving experience, print: Status: Eligible for a regular license.
      • If they have more than 3 years of driving experience, print: Status: Eligible for an advanced license.
  5. After determining the license type, print a summary line with the following format:
Summary: Age: 19, Experience: 2 years, Test Passed: true

Your output must match the exact format shown above, but with the appropriate license status based on the values of the variables.

Try it yourself

void main() {
  // Declare your variables here
  int age = 19;
  int drivingExperience = 2;
  bool hasPassedTest = true;
  
  // Implement the license eligibility rules
  
  
  // Print the summary
  print('Summary: Age: $age, Experience: $drivingExperience years, Test Passed: $hasPassedTest');
}

All lessons in Fundamentals