Question

In: Computer Science

Write a class FinancialAidApplicant which describes an applicant for financial aid and will be used by...

Write a class FinancialAidApplicant which describes an applicant for financial aid and will be used by a financial aid officer.

Qualification is based on annual household income and the number of people in the household. If the household income is less than $20,000, the applicant automatically qualifies regardless of how few people are in the household. If the household income is at least $20,000 but at most $60,000 and there are 4 or more people in the household, the applicant qualifies. If the household income is more than $60,000 but at most $150,000 and there are 6 or more people in the household, the applicant qualifies. For all other cases, the applicant does not qualify.

A tester program is provided to you in Codecheck, but there is no starter code for class FinancialAidApplicant.

You should declare static constants for the numbers mentioned above.

The class has a constructor that takes a String, a double, and an int as parameters

public FinancialAidApplicant(String name, double income, int numberOfPeople)

It also has four methods:

• public String getName() Gets the applicant's name.

• public void setNumberOfPeopleInHousehold(int people) Sets number of people in the household

• public void setHouseholdIncome(double income) Sets a new household income

• public boolean qualifies() Returns true if the applicant qualifies and false

Method qualifies should have one if-else if-else statement instead of multiple if statements.

Code check:

public class FinancialAidApplicantTester
{
   public static void main(String[] args)
   {
       FinancialAidApplicant applicant =
          new FinancialAidApplicant("Joe Programmer",19999, 1);
         
       System.out.printf("The name of the applicant: %s.%n", applicant.getName());
       System.out.println("Expected: The name of the applicant: Joe Programmer.");

       System.out.println(applicant.qualifies());
       System.out.println("Expected: true");
       
       applicant.setHouseholdIncome(20000);
       applicant.setNumberOfPeopleInHousehold(3);
       System.out.println(applicant.qualifies());
       System.out.println("Expected: false");
       
       applicant.setNumberOfPeopleInHousehold(4);
       System.out.println(applicant.qualifies());
       System.out.println("Expected: true");

       applicant.setHouseholdIncome(60000);
       applicant.setNumberOfPeopleInHousehold(4);
       System.out.println(applicant.qualifies());
       System.out.println("Expected: true");
       
       applicant.setNumberOfPeopleInHousehold(3);
       System.out.println(applicant.qualifies());
       System.out.println("Expected: false");
       
       applicant.setHouseholdIncome(60001);
       applicant.setNumberOfPeopleInHousehold(6);
       System.out.println(applicant.qualifies());
       System.out.println("Expected: true");
       
       applicant.setNumberOfPeopleInHousehold(5);
       System.out.println(applicant.qualifies());
       System.out.println("Expected: false");
       
       applicant.setHouseholdIncome(150000);
       applicant.setNumberOfPeopleInHousehold(6);
       System.out.println(applicant.qualifies());
       System.out.println("Expected: true");
       
       applicant =
          new FinancialAidApplicant("Mary Rowe",150001, 10);
 
       System.out.printf("The name of the applicant: %s.%n", applicant.getName());
       System.out.println("Expected: The name of the applicant: Mary Rowe.");

       System.out.println(applicant.qualifies());
       System.out.println("Expected: false");
   }
}

Solutions

Expert Solution

PROGRAM:

Please find below the test class as per the given requirements:

File Name: FinancialAidApplicant.java

public class FinancialAidApplicant {

                //constants for income and members

                private static final int QUALIFYING_INCOME = 20000;//a constant for minimum income

                private static final int QUALIFYING_INCOME_II = 60000;//a constant for income 60000

                private static final int MAX_INCOME = 150000;//a constant for income 150000

               

                //local private data members of the class

                private String name;

                private double income;

                private int numberOfPeople;

               

                public FinancialAidApplicant(String name, double income, int numberOfPeople) {//parameterized constructor

                                //set private data members as per the value provided in parameter

                                this.name=name;

                                this.income=income;

                                this.numberOfPeople=numberOfPeople;

                }

                public String getName() { //Gets the applicant's name.

                                return name;

                }

                public void setNumberOfPeopleInHousehold(int people) { //Sets number of people in the household

                                numberOfPeople= people;

                }

                public void setHouseholdIncome(double income) {// Sets a new household income

                                this.income = income;

                }

                public boolean qualifies() {//Returns true if the applicant qualifies and false

                                if(income<QUALIFYING_INCOME) {

                                                return true; //income is less than 20000, no need to consider people, return true

                                }

                                else if(income>=QUALIFYING_INCOME && income<=QUALIFYING_INCOME_II && numberOfPeople>=4) {

                                                return true;//people are 4 or more and income in between 20000 to 60000(including)

                                }

                                else if(income>QUALIFYING_INCOME_II && income <=MAX_INCOME && numberOfPeople >=6){

                                                return true;//people are 6 or more and income is more than 60000 to 150000(including)

                                }

                                else {//for all other cases

                                                return false;

                                }//end else part

                }//end method

}

File Name: FinancialAidApplicantTester.java

This is same as shared in question. No change in the file.

SCREENSHOT:

Below is the screenshot to understand the code indentation:

OUTPUT:

**Kindly comment if you need any assistance. Thanks!!


Related Solutions

Write a class FinancialAidApplicant which describes an applicant for financial aid and will be used by...
Write a class FinancialAidApplicant which describes an applicant for financial aid and will be used by a financial aid officer. Qualification is based on annual household income and the number of people in the household. If the household income is less than $20,000, the applicant automatically qualifies regardless of how few people are in the household. If the household income is at least $20,000 but at most $60,000 and there are 4 or more people in the household, the applicant...
Draw a UML diagram that describes a class that will be used to describe a product...
Draw a UML diagram that describes a class that will be used to describe a product for sale on Glamazon.com. The product has a name, a description, a price, ratings by many customers (1 to 5 stars), and a group of customer comments. New products have no ratings or comments by customers, but do have a name, description and price. The price can be changed and more customer ratings and comments can be added. A global average rating of all...
Create a class that holds data about a job applicant. Include a name, a phone number,...
Create a class that holds data about a job applicant. Include a name, a phone number, and four Boolean fields that represent whether the applicant is skilled in each of the following areas: word processing, spreadsheets, databases, and graphics: Include a constructor that accepts values for each of the fields. Also include a get method for each field. Create an application that instantiates several job applicant objects and pass each in turn to a Boolean method that determines whether each...
Write an article that describes all the analytical methods used for calculating the roundness error.
Write an article that describes all the analytical methods used for calculating the roundness error.
Java Write a class called Triangle that can be used to represent a triangle. Write a...
Java Write a class called Triangle that can be used to represent a triangle. Write a class called Describe that will interface with the Triangle class The Server • A Triangle will have 3 sides. It will be able to keep track of the number of Triangle objects created. It will also hold the total of the perimeters of all the Triangle objects created. • It will allow a client to create a Triangle, passing in integer values for the...
The application has class Magazine which describes one Magazine object. Class LLMagazineRec desribes linked list whose...
The application has class Magazine which describes one Magazine object. Class LLMagazineRec desribes linked list whose nodes have data of Magazine type and includes recursive method createArrayListRec which you have to implement. Class Driver has main method that creates myList as linked lists of magazines. It should invoke recursive method from class LLMagazineRec. WRITTEN IN JAVA 1.)code for magazine class: // Class Magazine describes magazine object that has title and number of pages public class Magazine { private int pages;...
you are the office manager of a small financial credit business. An international applicant that you...
you are the office manager of a small financial credit business. An international applicant that you never met before has qulified for funding but he is required to setup/procure SPV and Green Bond Guarantee based on your company and government policy in your country accordingly. Write an approval letter within a letterhead congratulating him for the approval and requesting the foreign company to setup an SPV with guarantee that they will receive the funding upon completion and full compliance.
= Which of the following describes how RNA and DNA are used in mitosis? A.-forms spindle...
= Which of the following describes how RNA and DNA are used in mitosis? A.-forms spindle fibers that attach to chromosomes B.-moves vesicles to the middle of the cell to form the cell plate. C.-leads to synthesis of proteins that assist in cell replication. D.-produce energy for cell division.
Which of the following statements best describes corporate goals? a. The proper goal of the financial...
Which of the following statements best describes corporate goals? a. The proper goal of the financial manager should be to attempt to maximize the firm’s expected cash flows, because this will add the most to the wealth of the individual shareholders. b. The riskiness inherent in a firm’s earnings per share (EPS) depends on the characteristics of the projects the firm selects, and thus on the firm’s assets. However, EPS is not affected by the manner in which those assets...
Which of the following best describes how to account for the difference between a company's financial...
Which of the following best describes how to account for the difference between a company's financial income and taxable income, under generally accepted accounting principles? Computation of deferred income tax based on temporary and permanent differences. Computation of deferred income tax based on permanent differences. Computation of income tax expense based on taxable income. Computation of deferred tax assets and liabilities based on temporary differences.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT