if(command != null && command.equals("calculate")) { //최초 요청 시 command가 null이면 계산기 화면을 출력하고, command값이 calculate이면 계산 결과를 출력합니다.
String result = calculate(Float.parseFloat(won), operator); pw.print("변환결과"); pw.print(""+ result + ""); pw.print("환율 계산기"); return; } pw.print(""); pw.print("환율 계산기"); pw.print("
"); pw.print(""); pw.close(); } // 원화를 선택한 외화로 환산합니다. private static String calculate(float won, String operator) { String result = null; if(operator.equals("dollar")) { result = String.format("%.6f", won / USD_RATE); }else if (operator.equals("en")) { result = String.format("%.6f", won / JPY_RATE); }else if (operator.equals("wian")) { result = String.format("%.6f", won / CNY_RATE); }else if (operator.equals("pound")) { result = String.format("%.6f", won / GBP_RATE); }else if (operator.equals("euro")) { result = String.format("%.6f", won / EUR_RATE); } return result; } }