Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A person qualifies for CalFresh program (money for food) if he/she makes less th

ID: 3778628 • Letter: A

Question

A person qualifies for CalFresh program (money for food) if he/she makes less than $1962 a month. You are given a Person class. A Person has a name and a monthly income. Modify the Person class to implement the Qualifiable interface and determine if a person is eligible for CalFresh. For the final, modify Runner. Remove the code to print true or false and print the name of each Person in the array that qualifies for CalFresh. This is the first time you have submitted a tester. If you have trouble understanding what to do, ask in Piazza.

Note: You will also need to put the Student class into the project.

Qualifiable.java

Student.java

Complete the following files:

Person.java

/**
* models a person with a name and an annualIncome
*/
public class Person
{
private String name;
private double monthlyIncome;
  
public Person(String theName, double income)
{
name = theName;
monthlyIncome = income;
}
  
public String getName()
{
return name;
}
  
public double getMonthlyIncome()
{
return monthlyIncome;
}
  

  

}

Runner.java

public class Runner
{
public static void main(String[] args)
{
Qualifiable[] candidates = new Qualifiable[5];

candidates[0] = new Person("Susan", 2000.0);
candidates[1] = new Person("Fred", 1961.99 );
candidates[2] = new Person("Jack", 1962.00);
candidates[3] = new Person("Amy", 1200.00 );
candidates[4] = new Student("Thong", 3.6 );
  
for (Qualifiable c : candidates)
{
System.out.println(c.qualifies());
}
}
}

Expected output

Explanation / Answer

Solution:

Class name: Runner.java

public class Runner

{

public static void main(String[] args)

{

Qualifiable[] candidates = new Qualifiable[5];
candidates[0] = new Person("Susan", 2000.0);
candidates[1] = new Person("Fred", 1961.99 );
candidates[2] = new Person("Jack", 1962.00);
candidates[3] = new Person("Amy", 1200.00 );
candidates[4] = new Student("Thong", 3.6 );
  
//Display the outputs names for calFresh Program
System.out.println("The names eligible for CalFresh program are as follow: ");
for(int i=0;i<5;i++)

{

candidates[i].qualifies();
}

}
}

Class Name: Student.java

public class Student implements Qualifiable
{

private String name;
private double gpa;
private double QUALIFYING_GPA = 3.54;
  
public Student(String theName, double theGpa)
{

name = theName;
gpa = theGpa;

}
  
public String getName()
{

return name;
}
  
public double getGPA()
{

return gpa;
}

public boolean qualifies()
{

return gpa >= QUALIFYING_GPA;
}

}

Class name: Person.java

public class Person implements Qualifiable
{

private String name;
private double monthlyIncome;
  
public Person(String theName, double income)
{

name = theName;
monthlyIncome = income;

}
  
public String getName()
{

return name;
}
  
public double getMonthlyIncome()
{

return monthlyIncome;
}


public boolean qualifies()

{

//Check the condition for CalFresh Program
if(monthlyIncome<1962)

{

/*Display the name eligible for calFresh program. */

System.out.println("Name:"+name);


return true;

}
else

return false;

}
}

Interface name: Qualifiable.java

public interface Qualifiable
{

boolean qualifies();
}

Sample Output:

The names eligible for CalFresh program are as follow:

Name:Fred
Name:Amy

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote