In: Computer Science
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.
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");
}
}