Semper Verita

Blogs personal de José Luis Pino Cofré

Desarrollo de cosas simples

dejar un comentario »

Quiero comenzar con algo simple. Una pequeña aplicación para tu móvil que permite calcular la nota da una prueba dado el porcentaje obtenido en esta. La aplicación esta desarrollada en java micro edition.

package develop.org;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
* @author Jose Luis Pino Cofre
*/
public class Calculate extends MIDlet implements CommandListener {
private Command exitCommand = new Command (“Exit”, Command.EXIT, 1);
private Command okCommand = new Command(“Calcular”, Command.OK,2);
private TextField t = new TextField(“Porcentaje “,”",4,TextField.DECIMAL);
private StringItem si = new StringItem(“Nota: “, “”);

private boolean firstTime;
private Form mainForm;

public Calculate () {
firstTime = true;
mainForm = new Form (“Calcular Nota”);
}

protected void startApp () {
if (firstTime) {
mainForm.append (“App que permite calcular nota con 60% corte”);
mainForm.append(t);
mainForm.append(si);
mainForm.addCommand (exitCommand);
mainForm.addCommand(okCommand);
mainForm.setCommandListener (this);
firstTime = false;
}
Display.getDisplay (this).setCurrent (mainForm);
}
public void commandAction (Command c, Displayable s) {
if (c == exitCommand) {
destroyApp (false);
notifyDestroyed ();
}
else
if (c == okCommand) {
double nota;
int p = Integer.parseInt(t.getString());
if (p<60)
nota = (double)p/2+10;
else
nota = (double)p*75/100-5;
si.setText(String.valueOf(nota));
}
}
protected void destroyApp (boolean unconditional) {
}
protected void pauseApp () {
}
}

Esta nota se calcula con un porcentaje de corte del 60%.

Imagen de la aplicación funcionando,

jp

Advertisement

Escrito por jpino

25 octubre, 2011 a 1:55 PM

Escrito en Perfil...

Etiquetado con ,

Deja un comentario

Please log in using one of these methods to post your comment:

Logo de WordPress.com

You are commenting using your WordPress.com account. Log Out / Cambiar )

Twitter picture

You are commenting using your Twitter account. Log Out / Cambiar )

Facebook photo

You are commenting using your Facebook account. Log Out / Cambiar )

Connecting to %s

Seguir

Get every new post delivered to your Inbox.