1
package iCanDoIt;
import java.util.Scanner;
import javax.swing.JOptionPane;
public class Practice {
public static void main(String[] args) {
String msg=JOptionPane.showInputDialog("Enter a number");
int num1=Integer.parseInt(msg);
String msg2=JOptionPane.showInputDialog("enter another number");
int num2=Integer.parseInt(msg2);
int addition=num1+num2;
String msg3=JOptionPane.showInputDialog("What is" + num1 + "+ " + num2 + " ? ");
int answer=Integer.parseInt(msg3);
while(num1+num2!=answer){
JOptionPane.showMessageDialog(null,"try again");
String answer2=JOptionPane.showInputDialog("wrong. what is " + num1 + "+" + num2 + "?");
int answer3=Integer.parseInt(answer2);
if (num1+num2==answer3)
JOptionPane.showMessageDialog(null,"GREAT job");
}
System.exit(0);
}
}
저는 초보자입니다.JOptionPane 및 While 루프 (사용자 입력 추가)
스캐너 입력이 꽤 이해하기 쉬운 것 같지만 어떤 이유로 JOptionPane을 사용하는 데 어려움을 겪고 있습니다.
어쨌든, 내 문제는 내가 "다시 시도"점점 계속, 내가 대답 올바른 얻을 후에도입니다 ...
내가 뭘 잘못 말해 주 시겠어요?
@ DaoWen- 아아! 너무 많은 의미가 있습니다. 정말 고맙습니다!!!! :) :) :) – user3104903