6A
An insurance company needs an application to automate the calculation of monthly car insurance premiums for an individual person. Complete the Insurance class. The Insurance class has a constructor that takes a Person object as a parameter (constructor provided). You are also given the Person class.
The cost of car insurance is based on age and gender. Here is a table of monthly premiums based on age and gender of the owner for new Honda Civic garaged near San Jose State.
| < 25 | 25 to 85 (exclusive) | >=85 | |
|---|---|---|---|
| Male | $85.50 | $55.00 | $92.00 |
| Female | $79.25 | $45.00 | $90.00 |
Implement these methods
public int clientAge() gets the age of the insured Person (from the Person object)public String clientGender() gets the gender of the insured Person (from the Person object)public void incrementAge() the person had a birthday. Increment their age.public double monthlyPremium() gets the monthly premium for this Person or -1 if the age is less than 16 (minimum driving age). If the gender is not "m" assume it is "f"Provide Javadoc.
For the draft, implement clientAge, clientGender, and incrementAge. Provide the Javadoc.
You will need to look at the documentation of the Person class to see how to use the Person class' methods. You can either look at the Javadoc in the source code for the Person class or you can toggle the drop down menu on the right from Source Code to Documentation to get documentation in the familiar Java API format.

Do not have instance variables of age and gender in the Insurance class.
6B
Complete the class SomeLoops. It has several methods that use loops. These problems aren't especially useful, but they will let you practice writing loops.
public String countSJSU(int count) returns a string that contains SJSU count times all on one line, separated by spaces. You must use a loop. The output for countSJSU(5) will look like this:
SJSU SJSU SJSU SJSU SJSU
public int sumEveryThird(int limit) finds the sum of every third number that is less than a given number starting with 3 - EXCEPT those divisible by 5. Use a loop in the final. (You will not need a loop in the draft.) If the limit is 21, you would calculate
3 + 6 + 9 + 12 + 18 = 48
and the method would return 48
public String noXYZ(String s) returns a string in which all the letters x, y, and z have been removed. You must use a loop.
No Javadoc required
For the draft, implement sumEveryThird to find the sum when the limit is 21. Do not use a loop for this. Just add the values in the code
(return 3 + 6 + ...).
But think about how you determine when to stop. You will remove this code in the final and use a loop instead. Do not just print the literal 48
6C
Implement the following methods for StartToFinish class.
A constructor that takes a single String parameter has been implemented for you.
The words will be separated by spaces, and you can assume the phase is well-behaved
A method called firstLetters that returns a string consisting of the first character of every word in the string. If the string is the empty string return the empty String
A method called lastLetters that returns a string consisting of the last letter of every word in the string. The trickiest part here is that if the last character before a space is not a letter (it might be a , or a ?), you need to get the character before that. (That will have to be a letter since we disallow a pattern like "12, " But a pattern like "cat, " would be valid and you want to get the "t") If the string is the empty string return the empty String
The isLetter method of the Character class will be useful.
| static boolean | isLetter(char ch) Determines if the specified character is a letter. |
Remember that a method with a return type of boolean will return either true or false. You might call the method something like this
if (Character.isLetter(ch))
{
...
}
Don't worry that the method has a modifier of static. We will cover static later. Right now just call the method with an argument of one character.
Include Javadoc for the every public class, method and constructor.
For the draft, implement firstLetters to return the first letter of the first word or the empty string if the string is empty. Implement lastLetters() as a stub. Include Javadoc for both methods.