Skip to Content Java Solaris Communities Partners My Sun Sun Store United States Worldwide

»  Spotlight Articles
»  Projects
»  Publications
»  People
»  Awards
»  Events
»  Downloads
»  Internships
»  Contrarian Minds
»  About Sun Labs
package opjtutorial.ccalc;

import java.io.*; import org.opj.*;

public class Main {   static { OPRuntime.roots.add(Main.class); }   private static Main self = new Main();

  private float exchangeRate;

  public static void main(String args[]) {     try {       BufferedReader in = new BufferedReader(new InputStreamReader(System.in));       while (true) {         System.out.print("Input command: ");         int command = in.read(); String arg = in.readLine();         switch (command) {         case 'x':           self.exchangeRate = Float.parseFloat(arg);           System.out.println("Exchange rate set to " + self.exchangeRate);           break;         case 'c':           {             float amount = Float.parseFloat(arg);             System.out.println("Amount " + amount + " converts to " + amount*self.exchangeRate);           }           break;         case 'q':           System.exit(0);           break;         default:           System.out.println("Unknown command " + command);         }         OPRuntime.checkpoint();       }     } catch (Exception e) {       System.out.println(e);       System.exit(-1);     }  }  

Would you recommend this Sun site to a friend or colleague?
Contact About Sun News Employment Privacy Terms of Use Trademarks Copyright 1994-2008 Sun Microsystems, Inc.