Wirelees Toolkit
import javax.microedition.midlet.*;
public class HelloMIDlet
extends MIDlet
implements CommandListener {
private Form mMainForm;
privateTextField txt1;
private TextField txt2;
int i;
int precio = 0;
int preciototal=0;
int cantidad;
float PrecioDescuento=0;
private Command Aceptar;
public HelloMIDlet(){
mMainForm = new Form ("Instituto CBtech Actividad Nº2 Punto 1");
txt1 = new TextField("Cantidad de Productos", null, 64, TextField.NUMERIC);
txt2 = new TextField("Precio delProducto", null, 64, TextField.NUMERIC);
Aceptar = new Command("Aceptar" ,Command.EXIT, 2);
mMainForm.append(txt1);
mMainForm.append(txt2);
mMainForm.append(new StringItem(null, "InstitutoCBTech Experto en Programación Java"));
mMainForm.addCommand(Aceptar);
mMainForm.addCommand(new Command("Salir", Command.EXIT, 0));
mMainForm.setCommandListener(this);
}public void startApp() {
Display.getDisplay(this).setCurrent(mMainForm);
}
public void pauseApp() {}
public void destroyApp(boolean unconditional) {}
// public voidcommandAction(Command c, Displayable s) {
// notifyDestroyed();
// }
public void commandAction(Command c, Displayable s){
if (c == Aceptar){
int valor1 =Integer.parseInt(this.txt1.getString());
precio = Integer.parseInt(this.txt2.getString());
preciototal = (preciototal + precio);
if (valor1 > 2 && valor1 < 5 )
PrecioDescuento =((precio) - ((precio) * 0.1));
mMainForm.append(new StringItem(null, " Precio unitario es de " + precio));
mMainForm.append(new StringItem(null, " La cantidad de Productos esde " + valor1));
mMainForm.append(new StringItem(null, " Con descuento del 10 %" + PrecioDescuento));
mMainForm.append(new StringItem(null, " Total Precio sin Descuento" +...
Regístrate para leer el documento completo.