수업소개
배우지 않은 개념을 이용해서 나의 앱을 만들어봅시다. 앞으로 여러분이 공부해볼만한 주제들을 소개하는 시간이기도 합니다. 다 보려고 하지 마시고, 흥미 있는 부분까지만 보시면 됩니다.
강의 5
강의 6
소스코드
public class AccountingIFApp { public static void main(String[] args) { double valueOfSupply = Double.parseDouble(args[0]); double vatRate = 0.1; double expenseRate = 0.3; double vat = valueOfSupply * vatRate; double total = valueOfSupply + vat; double expense = valueOfSupply * expenseRate; double income = valueOfSupply - expense; double dividend1; double dividend2; double dividend3; if(income > 10000.0) { dividend1 = income * 0.5; dividend2 = income * 0.3; dividend3 = income * 0.2; } else { dividend1 = income * 1.0; dividend2 = income * 0; dividend3 = income * 0; } System.out.println("Value of supply : " + valueOfSupply); System.out.println("VAT : " + vat); System.out.println("Total : " + total); System.out.println("Expense : " + expense); System.out.println("Income : " + income); System.out.println("Dividend 1 : " + dividend1); System.out.println("Dividend 2 : " + dividend2); System.out.println("Dividend 3 : " + dividend3); } }
강의 7
소스코드
public class AccountingArrayApp { public static void main(String[] args) { double valueOfSupply = Double.parseDouble(args[0]); double vatRate = 0.1; double expenseRate = 0.3; double vat = valueOfSupply * vatRate; double total = valueOfSupply + vat; double expense = valueOfSupply * expenseRate; double income = valueOfSupply - expense; double[] dividendRates = new double[3]; dividendRates[0] = 0.5; dividendRates[1] = 0.3; dividendRates[2] = 0.2; double dividend1 = income * dividendRates[0]; double dividend2 = income * dividendRates[1]; double dividend3 = income * dividendRates[2]; System.out.println("Value of supply : " + valueOfSupply); System.out.println("VAT : " + vat); System.out.println("Total : " + total); System.out.println("Expense : " + expense); System.out.println("Income : " + income); System.out.println("Dividend 1 : " + dividend1); System.out.println("Dividend 2 : " + dividend2); System.out.println("Dividend 3 : " + dividend3); } }
강의 8
소스코드
public class AccountingArrayLoopApp { public static void main(String[] args) { double valueOfSupply = Double.parseDouble(args[0]); double vatRate = 0.1; double expenseRate = 0.3; double vat = valueOfSupply * vatRate; double total = valueOfSupply + vat; double expense = valueOfSupply * expenseRate; double income = valueOfSupply - expense; System.out.println("Value of supply : " + valueOfSupply); System.out.println("VAT : " + vat); System.out.println("Total : " + total); System.out.println("Expense : " + expense); System.out.println("Income : " + income); double[] dividendRates = new double[3]; dividendRates[0] = 0.5; dividendRates[1] = 0.3; dividendRates[2] = 0.2; int i = 0; while(i < dividendRates.length) { System.out.println("Dividend : " + (income*dividendRates[i]) ); i = i + 1; } } }
강의 9
소스코드
public class AccountingMethodApp { public static double valueOfSupply; public static double vatRate; public static double expenseRate; public static void main(String[] args) { valueOfSupply = 10000.0; vatRate = 0.1; expenseRate = 0.3; print(); } public static void print() { System.out.println("Value of supply : " + valueOfSupply); System.out.println("VAT : " + getVAT()); System.out.println("Total : " + getTotal()); System.out.println("Expense : " + getExpense()); System.out.println("Income : " + getIncome()); System.out.println("Dividend 1 : " + getDiviend1()); System.out.println("Dividend 2 : " + getDiviend2()); System.out.println("Dividend 3 : " + getDiviend3()); } public static double getDiviend1() { return getIncome() * 0.5; } public static double getDiviend2() { return getIncome() * 0.3; } public static double getDiviend3() { return getIncome() * 0.2; } public static double getIncome() { return valueOfSupply - getExpense(); } public static double getExpense() { return valueOfSupply * expenseRate; } public static double getTotal() { return valueOfSupply + getVAT(); } public static double getVAT() { return valueOfSupply * vatRate; } }
강의 10
소스코드
class Accounting{ public static double valueOfSupply; public static double vatRate; public static double expenseRate; public static void print() { System.out.println("Value of supply : " + valueOfSupply); System.out.println("VAT : " + getVAT()); System.out.println("Total : " + getTotal()); System.out.println("Expense : " + getExpense()); System.out.println("Income : " + getIncome()); System.out.println("Dividend 1 : " + getDiviend1()); System.out.println("Dividend 2 : " + getDiviend2()); System.out.println("Dividend 3 : " + getDiviend3()); } public static double getDiviend1() { return getIncome() * 0.5; } public static double getDiviend2() { return getIncome() * 0.3; } public static double getDiviend3() { return getIncome() * 0.2; } public static double getIncome() { return valueOfSupply - getExpense(); } public static double getExpense() { return valueOfSupply * expenseRate; } public static double getTotal() { return valueOfSupply + getVAT(); } public static double getVAT() { return valueOfSupply * vatRate; } } public class AccountingClassApp { public static void main(String[] args) { Accounting.valueOfSupply = 10000.0; Accounting.vatRate = 0.1; Accounting.expenseRate = 0.3; Accounting.print(); // anotherVariable = ...; // anotherMethod = ...; } }
강의11
소스코드
class Accounting{ public double valueOfSupply; public double vatRate; public double expenseRate; public void print() { System.out.println("Value of supply : " + valueOfSupply); System.out.println("VAT : " + getVAT()); System.out.println("Total : " + getTotal()); System.out.println("Expense : " + getExpense()); System.out.println("Income : " + getIncome()); System.out.println("Dividend 1 : " + getDiviend1()); System.out.println("Dividend 2 : " + getDiviend2()); System.out.println("Dividend 3 : " + getDiviend3()); } public double getDiviend1() { return getIncome() * 0.5; } public double getDiviend2() { return getIncome() * 0.3; } public double getDiviend3() { return getIncome() * 0.2; } public double getIncome() { return valueOfSupply - getExpense(); } public double getExpense() { return valueOfSupply * expenseRate; } public double getTotal() { return valueOfSupply + getVAT(); } public double getVAT() { return valueOfSupply * vatRate; } } public class AccountingClassApp { public static void main(String[] args) { // instance 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(); a1.print(); } }