import javax.microedition.lcdui.*; import javax.microedition.midlet.*; /** * @author kiriman */ public class Plan extends MIDlet implements CommandListener { public Form f; public TextField tf, tf1, tf3; private String sss, doouuuu, igomgmhnmhmkhm; private Command ok = new Command("OK", Command.OK, 0); private Command cancel = new Command("OK", Command.OK, 0); public Display di; private double ss, do1, plan, zd; private int s4, sm, do4, dom, r4, rm, zdg, zdk, s, do2, r, rd; public Plan() { sss = "5.50"; doouuuu = "13.14"; igomgmhnmhmkhm = "50"; di = Display.getDisplay(this); } public void startApp() { f = new Form("Кондуктор"); tf = new TextField("Работаю с:", sss, 1000, TextField.DECIMAL); tf1 = new TextField("До:", doouuuu, 1000, TextField.DECIMAL); tf3 = new TextField("План:", igomgmhnmhmkhm, 1000, TextField.NUMERIC); f.append(tf); f.append(tf1); f.append(tf3); f.addCommand(ok); f.setCommandListener(this); di.setCurrent(f); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } public void commandAction(Command c, Displayable d) { if (c == ok) { sss = tf.getString(); doouuuu = tf1.getString(); igomgmhnmhmkhm = tf3.getString(); ss = Double.parseDouble(sss); do1 = Double.parseDouble(doouuuu); plan = Double.parseDouble(igomgmhnmhmkhm); Joooo(); f.deleteAll(); f.removeCommand(ok); f.addCommand(cancel); f.append("Время работы:\n" + r4 + "." + rm + "\nСдать в кассу:\n" + zdg + "." + zdk); } if (c == cancel) { startApp(); } } public void Joooo() { s4 = (int) ss; //5 sm = (int) (ss % s4 * 100); //50 do4 = (int) do1; //13 dom = (int) (do1 % do4 * 100); //14 s = (s4 * 60) + sm; do2 = (do4 * 60) + dom; if (do2 < s) { rd = (24 * 60) - s; r = rd + do2; } else { r = do2 - s; } bugaga(); } public void bugaga() { plan = plan * 100 / 60; zd = r * plan; r4 = r / 60; rm = r % 60; zdg = (int) (zd / 100); zdk = (int) (zd % 100); } }