밥을 먹는데 팁과 세금까지해서 얼마를 내야하는지 알아내는 소스
문제라고하기엔 너무 쉽지만 일단 포스팅해본다.
public class Arithmetic {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
double mealCost = scan.nextDouble(); // original meal price
int tipPercent = scan.nextInt(); // tip percentage
int taxPercent = scan.nextInt(); // tax percentage
scan.close();
double calcCost = mealCost + (mealCost*tipPercent)/100 + (mealCost*taxPercent)/100;
int totalCost = (int) Math.round(calcCost);
System.out.println("The total meal cost is " + totalCost + " dollars.");
}
}
'Algorithm' 카테고리의 다른 글
| ???? : 무얼 하려는 문제인지 모르겠.... (0) | 2016.10.26 |
|---|---|
| 소수 구하기 (0) | 2016.10.26 |