A person is eligible to be a US senator if they are at least
Solution
I am assuming, required programming language is C++
#include <iostream>
using namespace std;
string congress( int age_of_person, int years_of_citizenship ){
bool eligible_for_us_senator = false;
bool eligible_for_us_representative = false;
if( age_of_person >= 25 && years_of_citizenship >= 7){
eligible_for_us_representative = true;
}
if( age_of_person >= 30 && years_of_citizenship >= 9){
eligible_for_us_senator = true;
}
if( eligible_for_us_senator && eligible_for_us_representative ){
return \"Eligible for the Senate and the House\";
}
else if( eligible_for_us_representative ){
return \"Eligible only for the House\";
}
else{
//if not eligible_for_us_representative, then also not eligible_for_us_senator
return \"Not eligible for Congress\";
}
}
void test(){
string a = congress( 26, 8 );
cout << a << endl;
}
int main(){
test();
}
