fork download
  1. class Accounting{
  2. public static double valueOfSpply;
  3. public static double vatRate;
  4. public static double expenseRate;
  5. public static void print() {
  6. System.out.println("Value of supply : " +valueOfSpply);
  7. System.out.println("VAT : " + getVAT());
  8. System.out.println("Total : " + getTotal());
  9. System.out.println("Expense : " + getExpense());
  10. System.out.println("Income : " + getincome());
  11. System.out.println("Dividend1 : " + getDividend1());
  12. System.out.println("Dividend2: " + getDividend2());
  13. System.out.println("Dividend3 : " + getDividend3());
  14. }
  15. public static double getDividend1() {
  16. return getincome() * 0.5;
  17. }
  18. public static double getDividend2() {
  19. return getincome() * 0.3;
  20. }
  21. public static double getDividend3() {
  22. return getincome() * 0.2;
  23. }
  24. public static double getincome() {
  25. return valueOfSpply - getExpense();
  26. }
  27. public static double getExpense() {
  28. return valueOfSpply*expenseRate;
  29. }
  30. public static double getTotal() {
  31. return valueOfSpply + getVAT();
  32. }
  33. private static double getVAT() {
  34. return valueOfSpply*vatRate;
  35. }
  36.  
  37. }
  38. class Accounting2{
  39. public double valueOfSpply;
  40. public double vatRate;
  41. public double expenseRate;
  42. public void print() {
  43. System.out.println("Value of supply : " +valueOfSpply);
  44. System.out.println("VAT : " + getVAT());
  45. System.out.println("Total : " + getTotal());
  46. System.out.println("Expense : " + getExpense());
  47. System.out.println("Income : " + getincome());
  48. System.out.println("Dividend1 : " + getDividend1());
  49. System.out.println("Dividend2: " + getDividend2());
  50. System.out.println("Dividend3 : " + getDividend3());
  51. }
  52. public double getDividend1() {
  53. return getincome() * 0.5;
  54. }
  55. public double getDividend2() {
  56. return getincome() * 0.3;
  57. }
  58. public double getDividend3() {
  59. return getincome() * 0.2;
  60. }
  61. public double getincome() {
  62. return valueOfSpply - getExpense();
  63. }
  64. public double getExpense() {
  65. return valueOfSpply*expenseRate;
  66. }
  67. public double getTotal() {
  68. return valueOfSpply + getVAT();
  69. }
  70. private double getVAT() {
  71. return valueOfSpply*vatRate;
  72. }
  73.  
  74. }
  75. public class AccountingClassApp {
  76.  
  77. public static void main(String[] args) {
  78.  
  79.  
  80. Accounting a1 = new Accounting();
  81. a1.valueOfSupply = 10000.0;
  82. a1.vatRate = 0.1;
  83. a1.expenseRate = 0.3;
  84. a1.print();
  85.  
  86. Accounting a2 = new Accounting();
  87. a2.valueOfSupply = 20000.0;
  88. a2.vatRate = 0.05;
  89. a2.expenseRate = 0.2;
  90. a2.print();
  91.  
  92. }
  93. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:75: error: class AccountingClassApp is public, should be declared in a file named AccountingClassApp.java
public class AccountingClassApp {
       ^
Main.java:81: error: cannot find symbol
		a1.valueOfSupply = 10000.0;
		  ^
  symbol:   variable valueOfSupply
  location: variable a1 of type Accounting
Main.java:87: error: cannot find symbol
		a2.valueOfSupply = 20000.0;
		  ^
  symbol:   variable valueOfSupply
  location: variable a2 of type Accounting
3 errors
stdout
Standard output is empty