Driving Eligibility Checker

Driving Eligibility Checker

Using only if statements for the logic; make a program that prompts the user to input their age and whether they have a driving license.

For now you can rely on integer inputs of either 0 or 1 to check for a yes or no. Just make sure to include those instructions in the prompt to the user.

Output "You can legally drive." if the age is above 18 and they have a license.

Output "You need a driving license to drive" if the age is above 18, but they don't have a driving license.

Output "You are too young to drive." if they are below 18.

Answer

#include <iostream>

int main() {
	std::cout << "Input your age: ";
	int age;
	std::cin >> age;

	std::cout << "Do you have a drivers license? (1=yes, 0=no):";
	int license_status;
	std::cin >> license;

	if (age < 18)
	{
		std::cout << "You are too young to drive.";
	}
	if (age >= 18 && license_status == 1)
	{
		std::cout << "You can legally drive";
	}
	if (age >= 18 && license_status == 0)
	{
		std::cout << "You need a drivers license to drive.";
	}
}
Questions