java 프리랜서 세금 계산
문제
- 천단위 구분 하기.
코드
Main.java
package pack_Form; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("세전급여를 입력해 주세요(단위. 원) : "); int money = scanner.nextInt(); scanner.close(); Money obj = new Money(money); String salary = obj.mtdMoney(); System.out.print("실지급액 : " + salary + " 원"); } } }
Money.java
package pack_Form; public class Money { private int money; public Money(int money) { this.money = money; } public String mtdMoney() { int moneyParam = money - (int)(money*0.033); Format format = new Format(moneyParam); String salary = format.mtdFormat(); return salary; } }
Format.java
package pack_Form; import java.text.NumberFormat; public class Format { private int moneyParam; public Format(int moneyParam) { this.moneyParam = moneyParam; } public String mtdFormat() { String salary = NumberFormat.getInstance().format(moneyParam); return salary; } }
결과
Leave a comment