class Accounting{
public static double valueOfSpply;
public static double vatRate;
public static double expenseRate;
public static void print() {
System.
out.
println("Value of supply : " +valueOfSpply
); System.
out.
println("VAT : " + getVAT
()); System.
out.
println("Total : " + getTotal
()); System.
out.
println("Expense : " + getExpense
()); System.
out.
println("Income : " + getincome
()); System.
out.
println("Dividend1 : " + getDividend1
()); System.
out.
println("Dividend2: " + getDividend2
()); System.
out.
println("Dividend3 : " + getDividend3
()); }
public static double getDividend1() {
return getincome() * 0.5;
}
public static double getDividend2() {
return getincome() * 0.3;
}
public static double getDividend3() {
return getincome() * 0.2;
}
public static double getincome() {
return valueOfSpply - getExpense();
}
public static double getExpense() {
return valueOfSpply*expenseRate;
}
public static double getTotal() {
return valueOfSpply + getVAT();
}
private static double getVAT() {
return valueOfSpply*vatRate;
}
}
class Accounting2{
public double valueOfSpply;
public double vatRate;
public double expenseRate;
public void print() {
System.
out.
println("Value of supply : " +valueOfSpply
); System.
out.
println("VAT : " + getVAT
()); System.
out.
println("Total : " + getTotal
()); System.
out.
println("Expense : " + getExpense
()); System.
out.
println("Income : " + getincome
()); System.
out.
println("Dividend1 : " + getDividend1
()); System.
out.
println("Dividend2: " + getDividend2
()); System.
out.
println("Dividend3 : " + getDividend3
()); }
public double getDividend1() {
return getincome() * 0.5;
}
public double getDividend2() {
return getincome() * 0.3;
}
public double getDividend3() {
return getincome() * 0.2;
}
public double getincome() {
return valueOfSpply - getExpense();
}
public double getExpense() {
return valueOfSpply*expenseRate;
}
public double getTotal() {
return valueOfSpply + getVAT();
}
private double getVAT() {
return valueOfSpply*vatRate;
}
}
public class AccountingClassApp {
public static void main
(String[] args
) {
Accounting a1 = new Accounting();
a1.valueOfSupply = 10000.0;
a1.vatRate = 0.1;
a1.expenseRate = 0.3;
a1.print();
Accounting a2 = new Accounting();
a2.valueOfSupply = 20000.0;
a2.vatRate = 0.05;
a2.expenseRate = 0.2;
a2.print();
}
}