Introduction




Name of Experiment: Display Display Numbers between Two Gauge Values of NOKIA ASHA 501

Exp No: 7

Background: Student should have a basic knowledge of Java Programming.

Summary: After going through this experiment, student should be able to display number between two gauge values using for loop on NOKIA Asha 501 device.

Learning Objective: Here, Student should learn the procedure to to display number between two gauge values using for loop on NOKIA Asha 501 device.. After, doing this experiment user himself will be able to make an app to able to display number between two gauge values using for loop on NOKIA Asha 501 device..

Target

Target Platform:This experiment is tested on Nokia Asha Device 501.

Procedure

SourceCode

Source Code:

importjavax.microedition.lcdui.Alert;
importjavax.microedition.lcdui.Command;
importjavax.microedition.lcdui.CommandListener;
importjavax.microedition.lcdui.Display;
importjavax.microedition.lcdui.Displayable;
importjavax.microedition.lcdui.Form;
importjavax.microedition.lcdui.Gauge;
importjavax.microedition.midlet.MIDlet;
importjavax.microedition.midlet.MIDletStateChangeException;
public class Gauge_value extends MIDlet implements CommandListener {
Form gauge_val;
Gauge num1, num2;
Command done;
Alert alert;
publicGauge_value() {
// TODO Auto-generated constructor stub
gauge_val=new Form("Gauge Value");
num1=new Gauge("Number 1", true, 10, 0);
num2=new Gauge("Number 2", true, 10, 0);
done=new Command("OK", Command.OK, 0);
gauge_val.append(num1);
gauge_val.append(num2);
gauge_val.append("\nNicyKaurTaneja Roll no. 22\n VandanaKumari Roll no. 33");
gauge_val.addCommand(done);
gauge_val.setCommandListener(this);
}
protected void destroyApp(boolean unconditional)
throwsMIDletStateChangeException {
}
protected void pauseApp() {
}
protected void startApp() throws MIDletStateChangeException {
Display.getDisplay(this).setCurrent(gauge_val);
}
public void commandAction(Command c, Displayable d) {
int n1=num1.getValue();
int n2=num2.getValue();
if(c==done){
if(n1>n2){
alert=new Alert("invalid");
Display.getDisplay(this).setCurrent(alert);
}
else if(n1<n2){
gauge_val=new Form("show gauge values:");
gauge_val.setCommandListener(this);
for(inti=n1;i<=n2;i++){
gauge_val.append("\n"+i);
}
Display.getDisplay(this).setCurrent(gauge_val);}}}}

Snapshots



This is how the output appears on the emulator of NOKIA Asha SDK 1.0 on successful compilation of source code.

Observation

Observation: In this program, we used For Loop to Display Numbers between Two Gauge of NOKIA Asha 501 device.

Video Link

Download