Professional Documents
Culture Documents
ASSIGNMENT 04
Solution
Marks: 5
1. Write a java program for Tax calculation of property as per given class diagram. Make 5
objects of Taxable house and bus, and show their taxes. Attach screenshots of your
output as well.
For tax calculation:
InCity house= (estimatedValue / 1000) * 5 + 0.5 * area
Out of City house= (estimatedValue / 1000) * 3
For Bus= (value / 10) + 105 * numberOfSeats
Source Code:
public class Fixed_Property {
protected String location;
protected boolean incity;
protected double estimate_Value;
this.location=location;
incity=city;
estimate_Value=value;
}
public String getLocation(){
return(location);
}
}
public class TaxableHouse extends House implements ITaxable{
Reg_num=regnum;
this.value=value;
this.maxVelocity=maxvelocity;
}
public int getRegnum(){
return(Reg_num);
}}
public class Bus extends Vehichle{
protected int no_of_seat;
public Bus(int regnum, double maxvelocity,int noOfseats, double value) {
super(regnum, maxvelocity, value);
no_of_seat=noOfseats;
}
public int getTotalSeats(){
return(no_of_seat);
}}
public class TaxableBus extends Bus implements ITaxable{
3. What will happen if we are not implementing all the methods of an interface in class
which implements an interface?
Department of Computer Science CSC-210:Object-Oriented Programming
Bahria University Karachi Campus Semester 02 (Spring 2021)
Answer: If we are not implementing all the methods of an interface in class which
implements an interface then we must have to make this class abstract otherwise we
must have to provide the implementation of all the method.