Algorithm
총 금액 계산하기
코코콩
2016. 10. 26. 16:59
밥을 먹는데 팁과 세금까지해서 얼마를 내야하는지 알아내는 소스
문제라고하기엔 너무 쉽지만 일단 포스팅해본다.
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."); } }