6A
Note that I have consistently misspelled Finanial in both both the class and the tester. You need to misspell it too so Codeccheck will work. The best thing to do is to always copy the starter code so you have the same names I do. My apologizes. (updated 3/11/2019)
In this problem, you complete the class FinanialAidTester
which describes an applicant for financial aid and will be use by a financial aid officer. It has a method that determines if the applicant qualifies for financial aid. Here are some made-up rules telling who qualifies for aid.
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 less than or equal to $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 less than or equal to $150,000 and there are 6 or more people in the household, the applicant qualifies. If the household income is greater than $150,000, the applicant does not qualify no matter how many people are in the household.
FinanialAidTester
has a constructor that takes a String, a double, and an int as parameters
public FinanialAidTester(String name, double householdIncome, int numberOfPeopleInHousehold)
It also has methods:
public String getName()
gets the applicant's name. public boolean qualifies()
returns true if the applicant qualifies otherwise it returns falsepublic void setNumberOfPeopleInHousehold( int people)
sets number of people in the householdpublic int getNumberOfPeopleInHousehold()
gets number of people in the householdpublic void setHouseholdIncome( double income)
sets a new household incomeProvide Javadoc
Use nested ifs. There are other ways to do this but I want you to use nested ifs
For the draft, provide the instance variables, the constructor, and implement the setNumberOfPeopleInHousehold
and getNumberOfPeopleInHousehold()
methods. Implement setHouseholdIncome
and qualifies
as a stub. Note that a stub with return type boolean returns false. Provide the Javadoc. The Javadoc should document the code that will be in the final not the draft.
6B
Create a class NumberLoops. It has two methods that use loops. There are no instance variables. These problems aren't especially useful, but they will let you practice writing loops.
public double sumEveryThird(int limit)
gets the product of one and every third integer that is less than a given limit starting with 3 - EXCEPT those divisible by 5. The product will need to be a double to avoid overflow. Use a loop in the final. (You will not need a loop in the draft.) If the limit is 21, you would calculate
1.0 * 3 * 6 * 9 * 12 * 18 = 34992
and the method would return 34992.0
public String printNumbersUpTo(int limit)
gets a string with the numbers 0 to the limit (but not including the limit) in rows of 10. Each number is followed by a space. After 9, 19, 29, etc, you will had a newline ("\n") to the String. The remainder operator (%) will help you here. Use only one loop. Do not use nested loops.
Notice there are 2 test programs for the final.
For the draft, implement sumEveryThird
to find the product when the limit is 36. Do not use a loop for this. Just multiply the values in the code
(return 1.0 * 3 * 6 * ...). Do not just return 1.5713647488E10
But think about how you determine which numbers to include and when to stop. You will remove this code in the final and use a loop instead. Do not just print the literal answer
Javadoc is not required
6C
Write a class called Name
. The constructor takes a String parameter representing a person's full name. The name can by any number of words.
Provide methods
public String listLetters(
) gets a string with each letter of the name (including the space) on a new line. To do that, start with the empty string. Concatenate each letter followed by a newline character (\n)public String getName()
gets the name public int consonants()
gets the number of consonants in the name. A consonant is any letter that is not a vowel. For this problem assume the vowels are aeiou. Ignore case. "a" and "A" are both vowels. "b" and "B" are both consonants. Assume the only non-letters in the name will be spaces or -. Be smart about this. Do not use 21 if statements testing for "b", "c", "d", etcpublic String initials()
gets the initials of the name. Provide Javadoc
For the draft, implement the constructor and listLetters method. Provide Javadoc