/* * Main.java * * Created on February 18, 2007, 7:56 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package calc; import java.io.*; /** * * @author kcbanner */ public class Main { /** Creates a new instance of Main */ public Main() { } /** * @param args the command line arguments */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); System.out.print("First Number: "); System.out.flush(); String ain = in.readLine(); System.out.print("Operation: "); System.out.flush(); String operin = in.readLine(); System.out.print("Second Number: "); System.out.flush(); String bin = in.readLine(); Double a = Double.valueOf(ain); Double b = Double.valueOf(bin); if (operin == "+") { System.out.println(a + b); } else if (operin == "-") { System.out.println(a - b); } else if (operin == "*") { System.out.println(a * b); } else if (operin == "/") { System.out.println(a / b); } else { System.out.println("Invalid Operator: " + operin + "."); } } }