-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmilitary2.cpp
57 lines (44 loc) · 1.33 KB
/
military2.cpp
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
/*******
Reinier Swanepoel
CS111
2/17/2020
Military
Make a program that will display one of the messages below depending on the gender and age the user enters.
*******/
#include <iostream> //intro for any code
using namespace std; //instead of typing on everyline
int main () //start code
{ //variables
char gender;//either one character
int age; //any integer
int wait; //used to calc age needed to wait
cout << "Enter a gender."<<endl; //ask for gender
cin >> gender; //given
if (gender=='m' || gender=='M') //if you are a male enter the loop
{
cout << "Enter an age." << endl; //ask for age
cin >> age; //given
if (age <= 0) //has to be valid age
{
cout << "Invalid age."<<endl;
}
else if (age <= 16) //cant be a minor
{
wait = 17 - age;
cout << "You need to wait " << wait << " more years."<<endl;
}
else if (age >= 17 && age <= 42) // adult age is perfect
{
cout << "The military is hiring more people like you."<<endl;
}
else //if(age >= 43) //men
{
cout << "Thank you for using the system." << endl;
}
}
else if (gender == 'f' || gender == 'F') //if you are not male
cout << "Thank you for using the system, but we were only looking for men." <<endl;
else //if you are not male or female
cout << "Invalid gender" <<endl;
return 0;
}