비트교육_단기과정 while문 계산기 - 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num; float f; char calculation_opt; String choice = null; do { System.out.print("정수를 입력 : "); num = sc.nextInt(); System.out.print("실수를 입력 : "); f = sc.nextFloat(); System.out.print("+,-,*,/ => 연산을 입력 : "); calculation_opt = sc.next().charAt(0); switch (calculation_opt) { case '+': System.out.println(num + f); break; case '-': System.out.println(num - f); break; case '*': System.out.println(num * f); break; case '/': System.out.println(num / f); break; default: System.out.println("연산을 잘못입력하셨습니다"); break; } System.out.print("추가로 계산하시겠습니까? y or n : "); choice = sc.next(); while (!(choice.equals("y") || choice.equals("Y") || choice.equals("n") || choice.equals("N"))) { System.out.print("다시 입력하시오 : "); choice = sc.next(); } } while (choice.equals("y") || choice.equals("Y")); } Colored by Color Scripter cs 공유하기 URL 복사카카오톡 공유페이스북 공유엑스 공유 게시글 관리 구독하기'기'발하고 '창'의적인 블로그 Contents 당신이 좋아할만한 콘텐츠 3명 성적처리 프로그램 2022.06.24 한 사람 성적처리 프로그램 : 마기창 2022.06.23 while문 구구단 출력 2022.06.23 다중 for문 별 출력 2022.06.22 댓글 0 + 이전 댓글 더보기