Skip to content

Instantly share code, notes, and snippets.

@6LYTH3
Created July 16, 2011 07:01
Show Gist options
  • Save 6LYTH3/1086089 to your computer and use it in GitHub Desktop.
Save 6LYTH3/1086089 to your computer and use it in GitHub Desktop.
Problem_D2
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