Created
July 16, 2011 07:01
-
-
Save 6LYTH3/1086089 to your computer and use it in GitHub Desktop.
Problem_D2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main; | |
import java.io.File; | |
import java.util.Scanner; | |
import javax.script.ScriptEngine; | |
import javax.script.ScriptEngineManager; | |
public class Exp { | |
public static void main(String[] args) throws Throwable { | |
File file = new File("txt"); | |
Scanner sc = new Scanner(file); | |
ScriptEngineManager mpr = new ScriptEngineManager(); //ท่าไม้ตาย | |
ScriptEngine scp = mpr.getEngineByName("JavaScript"); | |
int count=1; | |
while (sc.hasNext()) { | |
String ExR = sc.nextLine(); | |
if(ExR.contains("E")) break; | |
System.out.println("case "+count++ +": "+scp.eval(ExR)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment