/* Program 4.1.1 from C++ Programming Lecture notes  */

/* Author: Rob Miller and William Knottenbelt
   Program last changed: 30th September 2023 */

/* This program evaluates whether a given test score 
   is a 'pass' for a candidate of a given age. */ 

#include <iostream>
using namespace std;

enum Logical {False, True};

Logical acceptable(int age, int score);
Logical alright(int age, int score);       /* alternative function */
	
/* START OF MAIN PROGRAM */
int main() 
{
	int candidate_age, candidate_score;
	
	cout << "Enter the candidate's age: ";
	cin >> candidate_age;
	cout << "Enter the candidate's score: ";
	cin >> candidate_score;
	
	if (alright(candidate_age, candidate_score)) 
		cout << "This candidate passed the test.\n";
	else
		cout << "This candidate failed the test.\n";
	
	return 0;
}
/* END OF MAIN PROGRAM */

/* FUNCTION TO EVALUATE IF TEST SCORE IS ACCEPTABLE */
Logical acceptable(int age, int score)
{
	if (age <= 14 && score >= 50)
		return True;
	if (age <= 16 && score >= 55)
		return True;
	if (score >= 60)
		return True;
	return False;
}
/*END OF FUNCTION */

/* ALTERNATIVE FUNCTION TO EVALUATE IF TEST SCORE IS ACCEPTABLE */
Logical alright(int age, int score)
{
	Logical passed_test = False;
	
	if (age <= 14 && score >= 50)
		passed_test = True;
	else if (age <= 16 && score >= 55)
		passed_test = True;
	else if (score >= 60)
		passed_test = True;

	return passed_test;
}
/*END OF FUNCTION */

 
