Write a class that contains variables to hold your tuition fee and your book fee. Display the sum of the variables. Save the class as Fees.java.
public class Fees {
private double tuitionFee;
private double bookFee;
public Fees(double tuitionFee, double bookFee) {
this.tuitionFee = tuitionFee;
this.bookFee = bookFee;
}
public double sumOfFees(){
return tuitionFee + bookFee;
}
}
public static void main(String[] args) {
System.out.println(new Fees(34.6, 32.8).sumOfFees());
}
Comments
Leave a comment