XHAENEUNG에 런타임 오류 문제... YW 런타임 오류가 뜨던데 어디서 틀렸나요?? ~~ java ackage alog; import java.util.Scanner; public class AAA { public static String[] ar = new String[20]; static int st = 0; public static void Select(String ar,String ar2){ if(ar.matches(".*[+].*")) { String temp,temp2; int len =0; len = ar.length(); int i = ar.indexOf("+"); temp = ar.substring(0, i); temp2 = ar.substring(i+1, len); Toint(temp,temp2,ar2,"+"); } if(ar.matches(".*[-].*")) { String temp,temp2; int len =0; len = ar.length(); int i = ar.indexOf("-"); temp = ar.substring(0, i); temp2 = ar.substring(i+1, len); Toint(temp,temp2,ar2,"-"); } if(ar.matches(".*[*].*")) { String temp,temp2; int len =0; len = ar.length(); int i = ar.indexOf("*"); temp = ar.substring(0, i); temp2 = ar.substring(i+1, len); Toint(temp,temp2,ar2,"*"); } if(ar.matches(".*[/].*")) { String temp,temp2; int len =0; len = ar.length(); int i = ar.indexOf("/"); temp = ar.substring(0, i); temp2 = ar.substring(i+1, len); Toint(temp,temp2,ar2,"/"); } } public static void Toint(String par1,String par2,String presult,String idx) { int ar1 = 0,ar2=0; int result=0; String i; int sum =0; String Checking="No"; if(par1.equals("zero")){ ar1 = 0; } if(par1.equals("one")){ ar1 = 1; } if(par1.equals("two")){ ar1 = 2; } if(par1.equals("three")){ ar1 = 3; } if(par1.equals("four")){ ar1 = 4; } if(par1.equals("five")){ ar1 = 5; } if(par1.equals("six")){ ar1 = 6; } if(par1.equals("seven")){ ar1 = 7; } if(par1.equals("eight")){ ar1 = 8; } if(par1.equals("nine")){ ar1 = 9; } if(par1.equals("ten")){ ar1 = 10; } if(par2.equals("zero")){ ar2 = 0; } if(par2.equals("one")){ ar2 = 1; } if(par2.equals("two")){ ar2 = 2; } if(par2.equals("three")){ ar2 = 3; } if(par2.equals("four")){ ar2 = 4; } if(par2.equals("five")){ ar2 = 5; } if(par2.equals("six")){ ar2 = 6; } if(par2.equals("seven")){ ar2 = 7; } if(par2.equals("eight")){ ar2 = 8; } if(par2.equals("nine")){ ar2 = 9; } if(par2.equals("ten")){ ar2 = 10; } if(presult.equals("zero")){ result = 0; } if(presult.equals("one")){ result = 1; } if(presult.equals("two")){ result = 2; } if(presult.equals("three")){ result = 3; } if(presult.equals("four")){ result = 4; } if(presult.equals("five")){ result = 5; } if(presult.equals("six")){ result = 6; } if(presult.equals("seven")){ result = 7; } if(presult.equals("eight")){ result = 8; } if(presult.equals("nine")){ result = 9; } if(presult.equals("ten")){ result = 10; } switch(idx) { case "+":{ sum = ar1+ar2; if(sum==result) { Checking="Yes"; ar[st] = Checking; st++; } else { Checking="No"; ar[st] = Checking; st++; } break; } case "-":{ sum = ar1-ar2; if(sum==result) { Checking="Yes"; ar[st] = Checking; st++; } else { Checking="No"; ar[st] = Checking; st++; } break; } case "*":{ sum = ar1*ar2; if(sum==result) { Checking="Yes"; ar[st] = Checking; st++; } else { Checking="No"; ar[st] = Checking; st++; } break; } case "/":{ sum = ar1/ar2; if(sum==result) { Checking="Yes"; ar[st] = Checking; st++; } else { Checking="No"; ar[st] = Checking; st++; } break; } } } public static void main(String[] args) { // TODO Auto-generated method stub Scanner scanner = new Scanner(System.in); int T =0; int j ,k; String sp; String[] temp = {""}; String[] temp2 = {""}; T = scanner.nextInt(); for(int a = 0;a<T;a++) { sp = scanner.next(); temp = sp.split("="); Select(temp[0],temp[1]); } for(j=0;j<st;j++) { System.out.println(ar[j]); } } } ~~~ 9년 전
0개의 댓글이 있습니다. 정회원 권한이 있어야 커멘트를 다실 수 있습니다. 정회원이 되시려면 온라인 저지에서 5문제 이상을 푸시고, 가입 후 7일 이상이 지나셔야 합니다. 현재 문제를 푸셨습니다.
YW
런타임 오류가 뜨던데 어디서 틀렸나요??
~~ java
ackage alog;
import java.util.Scanner;
public class AAA {
}
~~~
9년 전