CS46A Spring 19

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

It also has methods:

Provide 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.

6A draft:
6A final:

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

6B draft:
6B final:

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

Provide Javadoc

For the draft, implement the constructor and listLetters method. Provide Javadoc

 

6C draft:
6C final: