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

A person is eligible to be a US senator if they are at least 30 years old and ha

ID: 3937400 • Letter: A

Question

A person is eligible to be a US senator if they are at least 30 years old and have been a US citizen for at least 9 years. To be a US representative these numbers are 25 and 7, respectively. Write a function, called congress0, that takes two formal parameters: a person's age (int) and years of citizenship (int) as input and returns their eligibility for the Senate and House. The return value of the function is one of the following three (1) * 'Eligible for the Senate and the House, * (2) * 'Eligible only for the House, * or (3) * 'Not eligible for Congress.* The caller of the function congress0 in the test0 function then prints a message using the format shown in the next problem. You must use If-elif-else statements In your solution. Your congress0 function must not print anything. Do not Import external module In your solution.

Explanation / Answer

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();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote