11A
A student qualifies for financial aid if he/she makes less than $1962.50 a month and has at least a 2.0 grade point average. You are given a Student
class. (This is a little different than the one used in class.) A Student
has a name, a monthly income, and a grade point average (in that order).
For the draft you will modify the Student
class to implement the Qualifiable
interface and determine if a student is eligible for financial aid. Use the constants provided.
For the final, modify QualifiableRunner
. Remove the code from the draft in the for loop to print true or false (or use the version in Codecheck for the final) and print the name of each Student
in the array that qualifies for financial aid. You will need to submit the Student
class as well as the QualifiableRunner
. If you do not have a working version of Student
, you can get it from the draft solution.
This is the first time you have submitted a tester. If you have trouble understanding what to do, ask in Piazza.
For the draft, modify the Student
class to implement the Qualifiable
interface and determine if a student is eligible for financial aid. Do not modify the QualifiableRunner
.
11B
Modify the Newborn
class from last week to implement the Comparable
interface. If you need it, you can get a working version from the solutions
Newborns
are ordered first by length with the smallest coming first. If two Newborns
have the same length, the Newborns
are ordered alphabetically by name. If this Newborn
should come before the other Newborn,compareTo
returns a negative integer. If this Newborn
should come after the other Newborn
, it returns a positive integer. Otherwise, it returns 0.
Remember that you should not use == to compare doubles.
For the draft, add the "implements Comparable" clause to the Newborn
class header and implement compareTo
as a stub
Note: You will get a compiler warning about "unsafe or unchecked operations" when you compile NewbornTester
. You can safely ignore it for now.
11C
Write a class Food
. A Food
has a name and grams of protein. Implement the Comparable
interface. Food
s are ordered by grams or protein. If two Food
s have the same number of grams of protein., they are ordered alphabetically be name.
Provide Javadoc
When you implement a method from an interface, you can add @Override above the method and Javadoc will use the Javadoc provided in the interface implementation
For the draft, write the Food
class. A Food
constructor takes name and grams of protein. (a double) in that order. It has getter methods for the instance variables but no setters. (Food
class is immutable). Do not implement Comparable in the draft. Do that in the final
Note: You will get a compiler warning about "unsafe or unchecked operations" when you compile FoodTester for the draft. You can safely ignore it for now.