자바 무한반복 사칙연산 조건문을 수정하고 싶습니다.

익명 사용자의 이미지

아래 프로그램은 무한 한복 계산인데요.
이건 배운대로 한건데
여기서 숫자를 따로 2번 입력 받는게 아니라
한번에 2개를 입력하고 다음에 바로 연산자를 입력해서 출력하고 싶습니다.

또 지금은 첫 번째 숫자를 정해진 숫자로 입력하면 끝나는 반복문 인데요.
이걸 코드 마지막에 계속할거냐고 질문하고 N 이라고 답하면 끝나는 프로그램으로 만들고 싶습니다.
조건문을 어디로 옮기면 이렇게 바꿀수 있을까요?

import java.util.Scanner;
 
public class nuber2 {
 
	    public static void main(String[] args) {
 
	        Scanner scan = new Scanner(System.in);
 
	        double x = 0;
	        double y = 0;
	        String z = "";
 
	        while (true) {
	        	System.out.println("Hi, I am really good at math! Put me to the test.");
	            System.out.print("Please enter number and then press Enter: ");
	            x = scan.nextDouble();
 
	            if (x == 999) {
	                System.out.print("Bye bye!");
	                return;
	            } else {
 
	                System.out.print("Please enter number and then press Enter: ");
	                y = scan.nextDouble();
 
	                System.out.print("Please enter one of the operations +, -, * or / and press Enter:");
	                z = scan.next();
 
	                switch (z) {
	                case "+":
	                    System.out.println( + x + " + " + y + " = " + (x + y) );
	                    System.out.println("I'm great at subtraction!\n");
	                    break;
	                case "-":
	                    System.out.println( + x + " - " + y + " = " + (x - y) );
	                    System.out.println("I'm great at subtraction!\n");
	                    break;
	                case "*":
	                    System.out.println( + x + " * " + y + " = " + (x * y) );
	                    System.out.println("I'm great at subtraction!\n");
	                    break;
	                case "/":
	                    System.out.println( + x + " / " + y + " = " + (x / y) );
	                    System.out.println("I'm great at subtraction!\n");
	                    break;
	                default:
	                    System.out.println("잘못된 연산자입니다.\n");
	                } } }}}
shint의 이미지

http://goorm.io

package project;
 
import java.io.*;
import java.util.StringTokenizer;
import java.util.Scanner;
 
 
//Class Scanner
//https://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html
 
//[JAVA] 문자열 입력과 출력 (Scanner)
//http://hyeonstorage.tistory.com/136
 
public class Main
{
    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
 
        double x = 0;
        double y = 0;
        String z = "";
 
        while (true)
        {
        	System.out.println("Hi, I am really good at math! Put me to the test.");
            System.out.print("Please enter number and then press Enter: ");
            x = scan.nextDouble();
            System.out.println(x);
            y = scan.nextDouble();
            System.out.println(y);
 
            if (x == 999) 
            {
                System.out.print("Bye bye!");
                return;
            }
            else
            {
//                 System.out.print("Please enter number and then press Enter: ");
//                y = scan.nextDouble();
 
                System.out.print("Please enter one of the operations +, -, * or / and press Enter:");
                z = scan.next();
 
                switch (z)
                {
                case "+":
                    System.out.println( + x + " + " + y + " = " + (x + y) );
                    System.out.println("I'm great at subtraction!\n");
                    break;
                case "-":
                    System.out.println( + x + " - " + y + " = " + (x - y) );
                    System.out.println("I'm great at subtraction!\n");
                    break;
                case "*":
                    System.out.println( + x + " * " + y + " = " + (x * y) );
                    System.out.println("I'm great at subtraction!\n");
                    break;
                case "/":
                    System.out.println( + x + " / " + y + " = " + (x / y) );
                    System.out.println("I'm great at subtraction!\n");
                    break;
                default:
                    System.out.println("잘못된 연산자입니다.\n");
                }
            }
        }
    }
}

----------------------------------------------------------------------------
젊음'은 모든것을 가능하게 만든다.

매일 1억명이 사용하는 프로그램을 함께 만들어보고 싶습니다.
정규 근로 시간을 지키는. 야근 없는 회사와 거래합니다.

각 분야별. 좋은 책'이나 사이트' 블로그' 링크 소개 받습니다. shintx@naver.com