Click here to Skip to main content
15,665,276 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
So i am new to java programming and struggling with interfaces, abstract class, set and get methods. i know these are the basics of OOP.

CAN someone please help me with the following part of my problem:
in iterface EssentialLivingCosts what should i include more so that i can access it from the class OncampusStudents

Write a program that computes the cost of yearly expenses of a university student using Object Oriented Programming. Code using the conditions below.

1. Make an Abstract UniversityStudent Class to code the conditions below. You must use constructor, setters and getters and make the fields private.

For all students: name and year (freshman, sophomore, junior, senior) (These are all fields except year which is an ArrayList) number of courses for the year (Assuming each course is 3 credits) (This is a field and Assign a constant fee value of 1000.30$/course)

2. Make an Interface with name EssentialLivingCost which has the 3 methods to calculate: costs of food, textbooks and misc. (clothing, entertainment etc.). (This is an abstract methods)

3. Make 2 concrete classes known as OnCampusStudent and OffCampusStudent. These classes extend the UniversityStudent Class and Implement the EssentialLivingCost Interface. Code the respective methods accordingly and for OnCampusStudent assign cost of housing for a year to be 12000$/year. For OffCampusStudent, ask his place of dwelling. If Surrey, the cost of housing is 7200$/year and if Burnaby it is 13200$/year.

4. Now code the Main Class, ask here the name of the student, his year of study, cost of food, textbooks and misc, his place of living, number of courses in the year. Use instantiated objects from the 2 concrete classes to find the total cost of the student for the year. Print the Student’s name, his year at the school and his total estimated yearly cost.

What I have tried:

public interface EssentialLivingCost {
public abstract double food();
public abstract double books();
public abstract double clothes();
public abstract double transport();
public abstract double misc();

Updated 29-Jun-18 19:24pm
Richard MacCutchan 30-Jun-18 3:46am    
Start with point 1 as instructed, and code only the items listed. If you need to see samples of abstract classes and interfaces, then Google will find many.

1 solution

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

In this case, read the question again, carefully. It sets out exactly what you need to do, and the order in which you must do it. You only need three methods in your EssentialLivingCost interface, and you need to implement that interface in the concrete classes!
Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900