for 루프를 만드는 방법을 알아낼 수 없으므로 추가 (1)를 수행 한 후에 다시 메뉴로 돌아갑니다. 나는 이것을 위해서 for 루프를 사용할 필요가있다.main에서 FOR 루프를 사용하는 방법
공간을 절약하기 위해 나머지 코드는 잘라 냈습니다. 그래서 나는 단지 추가에 도움이 필요하고 나머지는 할 수 있습니다. 는 (이 사이트를 사용하지 않는다, 그래서 제대로 코드를 게시하는 방법을 잘 모릅니다.)
public static void main (String args[])
{
Scanner userInput = new Scanner(System.in);
int add, add2, sub, sub2, multi, multi2, divi, divi2, rema, rema2, power, power2, Conf;
System.out.println("(1) Addition~");
System.out.println("(2) Subtraction~");
System.out.println("(3) Multiply~");
System.out.println("(4) Divide~");
System.out.println("(5) Remainder~");
System.out.println("(6) Power~");
System.out.println("(7) Quit~");
Conf = userInput.nextInt();
if(Conf == 1)
{
System.out.print("Enter first number to add: ");
add = userInput.nextInt();
System.out.print("Enter second number to add: ");
add2 = userInput.nextInt();
Ansr();
Adder(add, add2);
Sp();
}
else if(Conf == 7);
System.out.println("Exiting Program...");
System.exit(0);
userInput.close();
}
}
솔직히 매우 당신이 실제로 원하는 것을 혼동하고있다. 뭐가 문제 야? 코드에서 무엇을하고 싶습니까? 뭐하는거야? –
while while 루프가 더 적절하다고 생각합니다. 'while (Conf! = 7) '과 같은 것. 'Conf = 0'을 초기화하고 변수 선언과 초기화 후에 모든 것을이 루프 안에 넣습니다. –
그리고'switch'는 여러개의'if-else' 구조체를 읽기가 쉬울 것입니다. –