import java.io.*;
import javax.swing.*;
import javax.tools.*;
import java.util.*;
import java.lang.Integer;
import java.awt.*;
import java.awt.event.*;
import java.awt.font.*;
import java.awt.geom.*;
import java.awt.image.*;
import javax.swing.*;
import java.util.Locale;
import java.text.*;
import java.util.*;
import javax.swing.table.*;
import static java.lang.Math.*;

public class realtime3A
{          
     public static void compile(String name)
     {
	  try{
      JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
      int rc = javac.run(null,null,null,name);}
      catch(NullPointerException e1) {System.err.println("NULL POINTER");} 
     }
         
 public static void createfunction(String name,String function) 
 {
 String s="";
 String name1=name+".java";
 try {PrintWriter ffout=new PrintWriter(new BufferedWriter(new FileWriter(name1))); 
 s+="class "+name+" extends f_x\n";
 s+=" {\n";
 s+=" public double func (double x)\n";
 s+="{ double y="+function+";\n";
 s+=" return y;\n";
 s+="}\n";
 s+="}\n";
 ffout.println(s);
 //System.out.println(s);
 ffout.close();
 }
 catch(IOException e1) {System.err.println("girdi hatası.");} 
 catch(NumberFormatException e2){}; 
 }
     
     public realtime3A()
     {
	 String fileName="fa";    
	 String function=JOptionPane.showInputDialog("Enter function statement f(x) ");
	 createfunction(fileName,function);
	 compile(fileName+".java"); 
	 } 
}
