JAVA coding 자바코딩 - 이름, 기본급 입력 후 세금 계산 프로그래밍
자바 프로그램 연습을 해보았다. 결국 자료를 입력하고 원하는 값을 출력하도록 만드는 프로그램을 한번 간단히 해보았다.
import java.util.Scanner;
public class Practice1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
//선언
int basePay=0; //기본급
double salary=0; //월급
double tax=0; //세금
String name=""; //이름
//입력
System.out.print("이름 입력 : ");
name = sc.next();
System.out.print("기본급 입력 : ");
basePay = sc.nextInt();
//연산
tax = basePay * 0.033;
salary = basePay - tax;
//출력
System.out.println();
System.out.println("*** " + name + "의 월급 ***");
System.out.println("기본급 : " + basePay + "원");
System.out.printf("세금 : %.0f원\n", tax);
System.out.printf("월급 : %.0f원", salary);
}
}