Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

simple Java program 4

BunkerHillBroad
BunkerHillBroad 


use file Congress.java The following requirement for membership in the Congress of the United States are quoted from Article I of the Constitution of the United States: No Person shall be a Representative who shall not have attained to the Age of twenty-five Years, and been seven Years a Citizen of the United States, and who shall not, when elected, be an Inhabitant of that State in which he shall be chosen. No Person shall be a senator who shall not have attained to the Age of thirty Years, and been nine Years a Citizen of the United States, and who shall not, when elected, be an Inhabitant of that State for which he shall be chosen. Write a method named eligibleForSenate that returns a boolean value, and another method named eligibleForHouse that also returns a boolean value. Both methods accept two integer arguments (via parameters named age and lengthOfCitizenship), and each returns the corresponding congressional eligibility as a boolean (not Boolean) value. Use these two eligibility methods within a Java program whose main method requests input from the user, and then calls upon these methods in order to produce appropriate output that gets phrased as shown below. Here are 3 sample executions of your program: CONGRESS ELIGIBILITY Enter age of candidate: 37 Enter years of U.S. citizenship: 3 The candidate is NOT eligible for election to either the House of Representatives or the Senate. CONGRESS ELIGIBILITY Enter age of candidate: 47 Enter years of U.S. citizenship: 8 The candidate is eligible for election to the House of Representatives but is NOT eligible for election to the Senate. CONGRESS ELIGIBILITY Enter age of candidate: 35 Enter years of U.S. citizenship: 25 The candidate is eligible for election to both the House of Representatives and the Senate. Attachments
Tags Clarifications

Answers

Solution for Congress java program

mariobeka
mariobeka 



Below a screenshot of the program running and the implementation of the Congress java class. Attachments
Congress.java (1 K) Download Preview
the candidate: "); int age = sc.nextInt(); System.out.print("Enter years of U.S. citizenship: "); int years = sc.nextInt(); System.out.println(getStatement(eligibleForHouse(age, years), eligibleForSenate(age, years))); sc.close(); } static String getStatement(boolean eligibleForHouse, boolean eligibleForSenate) { if (eligibleForHouse && eligibleForSenate) { return "The candidate is eligible for election to both the House

Screen Shot 2016-11-11 at 19.42.22.png (31 K) Download Preview

Screenshots
Screenshot
Purchase Answer