I need to write a program that decides if you can apply for the job or not. After asking a series of questions (all the questions) the program then needs to print out whether you can apply or not.
Here are the requirments for the job
• If you are male between the ages of 18 and 30 (inclusive) you may apply.
• If you are female between the ages of 18 and 32 (inclusive) you may apply.
• If you are male between the ages of 18 and 35 (inclusive) and either were in the
military or you can do at least 50 pushups in a row you may apply.
• If you are female between the ages of 18 and 40 (inclusive) and either were in the
military or you can do at least 30 pushups in a row you may apply.
• No one else is eligible.
I have started this code and it compiles, but it prints out you may apply twice and sometimes even says you cannot apply, any help is greatly appreciated
#include <iostream>
#include <string>
using namespace std;
int main ()
{
int age, pushups;
string firstname,lastname, military, sex;
cout << "What is your full name? ";
cin >> firstname >> lastname;
cout << "How old are you? ";
cin >> age;
cout << "Were you ever in the military (yes/no)? ";
cin >> military;
cout << "How many pushups can you do in a row? ";
cin >> pushups;
cout << "Are you <m>ale of <f>emale? ";
cin >> sex;
if ((age >= 18 && age <= 30 && sex == "m") || (age >= 18 && age <= 35 && sex == "m" && pushups < 50 || military == "yes"))
{
cout << "You can apply" << endl;
}
if ((age >= 18 && age <= 32 && sex == "f") || (age >= 18 && age <= 40 && sex == "f" && pushups < 30 || military == "yes"))
{
cout << "You can Apply" << endl;
}
else if (age <=18 || age >= 40 ||pushups > 50 )
{
cout << "You MAY NOT apply";
}
}