Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

write a program that will verify eligibility of joining the military from the us

ID: 3767616 • Letter: W

Question

write a program that will verify eligibility of joining the military from the user’s gender and age.

Make the following 3 functions in addition to the main.

function 1 : GetInfo

Enter first name: David

Enter gender: m

Enter age: 21

Function 2: VerifyEligibility

No female

If male, he must be at least 18 This function returns true if eligible or false otherwise.

Function 3: PrintLetter

if(eligible)

cout << “Dear “ << name << “ Please join the military” << endl;

else

cout << “Thank you for applying.” << endl;

Explanation / Answer

#include <iostream>

#include <string>

using namespace std;

void GetInfo(string &first,char &gender,int &age)

{

cout << "Enter first name: ";

cin >> first;

cout << "Enter gender: ";

cin >> gender;

cout << "Enter age: ";

cin >> age;

}

bool VerifyEligibility(char gender,int age)

{

if(gender=='f')

return false;

else

{

if(age>=18)

return true;

else

return false;

}

}

void PrintLetter(string first,char gender,int age)

{

bool eligible = VerifyEligibility(gender, age);

if(eligible)

cout << "Dear " << first << " Please join the military" << endl;

else

cout << "Thank you for applying." << endl;

}

int main() {

string first;

int age;

char gender;

GetInfo(first, gender, age);

PrintLetter(first, gender, age);

return 0;

}