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 pWrite 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 otherwise

For the draft, provide a stub for method qualifies to return false and implement all others. Method qualifies should have one if-else if-else statement instead of multiple if statements. Codecheck link for 6A draft Codecheck link for 6A final 6B Create a Java application NumberLoops to practice loops. The draft has one loop to calculate a product and the final will add another loop to print integers in a required format. There is no starter code for the problem. Draft Use a Scanner to input an integer then compute and display the product of all positive integers that are less than the input number and multiple of 3. If no numbers satisfy the conditions, then print out 1 for the product. Use a double for the product to avoid overflow and print out it without any decimal digits using the format specifier “%.0f”. Numbers 1 and 3 are allowed for the draft and will not be considered as magic numbers. Sample run Enter an integer: 36 The product is 7071141369600. Final After printing out the product, enter another integer then print out all non-negative integers less than the input integer, starting with 0. Print one space after each integer and one additional space before an integer if it is less than 10. Print 10 integers per row, except the last row which may have less than 10 integers. In addition to 1 and 3, numbers 9 and 10 are allowed for the final and will not be considered as magic numbers. The remainder operator (%) will help you here to decide when to call println() to go to the next line. Use only one loop. Do not use nested loops.

Sample run Enter an integer: 36

The product is 7071141369600.

Enter another integer: 36

0 1 2 3 4 5 6 7 8 9

10 11 12 13 14 15 16 17 18

19 20 21 22 23 24 25 26 27 28 29

30 31 32 33 34 35

Codecheck link for 6B draft Codecheck link for 6B final 6C Write a class called Name.

A tester program is provided in Codecheck, but there is no starting code for the Name class.

The constructor takes a String parameter representing a person's full name. A name can have multiple words, separated by single spaces.

The only non-letter characters in a name will be spaces or -, but not ending with either of them.

The class has the following methods. • public String getName() Gets the name string.

• public int consonants()

Gets the number of consonants in the name. A consonant is any character that is not a vowel, the space or -. For this problem assume the vowels are aeiou. Ignore case. "a" and "A" are both vowels. "b" and "B" are both consonants. You can have only one if statement in the method and the if condition cannot have either && or ||. Do not use the switch statement, which is basically the same as an if statement with multiple alternatives. Hint: call method contains().

• public String initials()

Gets the initials of the name. Do not use nested loops for the method. Hint for initials(): Each word after the first is preceded by a space. You can use the String method indexOf (" ", fromIndex) to control a while loop and to determine where a new word starts. This version of indexOf() returns the index of the first space starting at the fromIndex. The call of indexOf (" ", fromIndex) returns -1 if the space is not found in the string. Remember that the name does not have 2 consecutive spaces and does not end in a space.eople 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 otherwise For the draft, provide a stub for method qualifies to return false and implement all others. Method qualifies should have one if-else if-else statement instead of multiple if statements.

Codecheck link for 6A draft Codecheck link for 6A final 6B Create a Java application NumberLoops to practice loops. The draft has one loop to calculate a product and the final will add another loop to print integers in a required format. There is no starter code for the problem. Draft Use a Scanner to input an integer then compute and display the product of all positive integers that are less than the input number and multiple of 3. If no numbers satisfy the conditions, then print out 1 for the product. Use a double for the product to avoid overflow and print out it without any decimal digits using the format specifier “%.0f”. Numbers 1 and 3 are allowed for the draft and will not be considered as magic numbers. Sample run Enter an integer: 36 The product is 7071141369600. Final After printing out the product, enter another integer then print out all non-negative integers less than the input integer, starting with 0. Print one space after each integer and one additional space before an integer if it is less than 10. Print 10 integers per row, except the last row which may have less than 10 integers. In addition to 1 and 3, numbers 9 and 10 are allowed for the final and will not be considered as magic numbers. The remainder operator (%) will help you here to decide when to call println() to go to the next line. Use only one loop. Do not use nested loops. Sample run Enter an integer: 36 The product is 7071141369600. Enter another integer: 36 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 Codecheck link for 6B draft Codecheck link for 6B final 6C Write a class called Name. A tester program is provided in Codecheck, but there is no starting code for the Name class. The constructor takes a String parameter representing a person's full name. A name can have multiple words, separated by single spaces. The only non-letter characters in a name will be spaces or -, but not ending with either of them. The class has the following methods. • public String getName() Gets the name string. • public int consonants() Gets the number of consonants in the name. A consonant is any character that is not a vowel, the space or -. For this problem assume the vowels are aeiou. Ignore case. "a" and "A" are both vowels. "b" and "B" are both consonants. You can have only one if statement in the method and the if condition cannot have either && or ||. Do not use the switch statement, which is basically the same as an if statement with multiple alternatives. Hint: call method contains(). • public String initials() Gets the initials of the name. Do not use nested loops for the method. Hint for initials(): Each word after the first is preceded by a space. You can use the String method indexOf (" ", fromIndex) to control a while loop and to determine where a new word starts. This version of indexOf() returns the index of the first space starting at the fromIndex. The call of indexOf (" ", fromIndex) returns -1 if the space is not found in the string. Remember that the name does not have 2 consecutive spaces and does not end in a space.

Solutions

Expert Solution

PLEASE GIVE IT A THUMBS UP, I SERIOUSLY NEED ONE, IF YOU NEED ANY MODIFICATION THEN LET ME KNOW, I WILL DO IT FOR YOU

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

}

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

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