-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmilitaryFunc.cpp
More file actions
74 lines (61 loc) · 1.48 KB
/
militaryFunc.cpp
File metadata and controls
74 lines (61 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/****************************************
James Bertel
CS111
Lab 5-2
10-13-17
This program will verify the eligibility of joining the military from the
user’s gender and age. Make the following 4 functions in addition to the main.
****************************************/
#include <iostream>
using namespace std;
void showProgInfo();
void getInfo(string &name, char &gen, int &age);
bool verifyEligibility(char gen, int age);
void printLetter(string name, bool elig);
int main()
{
string name;
char gen;
int age;
showProgInfo();
getInfo(name, gen, age);
bool elig = verifyEligibility(gen, age);
printLetter(name, elig);
return 0;
}
void showProgInfo()
{
cout << "****************************************************" << endl;
cout << "This program will tell you if you are eligible to join the military." << endl;
cout << "****************************************************" << endl;
}
void getInfo(string &name, char &gen,int &age)
{
cout << "Enter first name: ";
cin >> name;
cout << "Enter gender (m or f): ";
cin >> gen;
cout << "Enter age: ";
cin >> age;
}
bool verifyEligibility(char gen, int age)
{
bool elig;
if(gen=='m' || gen=='M')
{
if(age >= 17 && age <= 42)
elig=true;
else
elig=false;
}
else
elig=false;
return elig;
}
void printLetter(string name, bool elig)
{
if(elig==true)
cout << "Dear " << name << ", Please consider joining the military" << endl;
else
cout << "Thank you for applying." << endl;
}