Design an Application Program for Mobile Phones (1)

download Design an Application Program for Mobile Phones (1)

of 5

Transcript of Design an Application Program for Mobile Phones (1)

  • 8/18/2019 Design an Application Program for Mobile Phones (1)

    1/5

    Aim: Design an application program for Mobile Phones

    Resource Required: Wireless Toolkit/Net Beans/Eclipse, using J2ME/ n!roi!"

    Theory:Example: #alculator

    Design a simple calculator $ith four basic operations such as !!ition, %ubtraction,Multiplication,

    an! !i&ision

    Example:calcu.java

    import javax.microedition.lcdui.*;

    import javax.microedition.midlet.*;

    import java.io.*;

    public class calcu extends MIDlet implements CommandListener

    {

    private Form form;

    private Display display;

    private extField input!" input#;

    private Command add" sub" mul"div;

    private $trin%Item item;

    public calcu&'

    { (

    public void start)pp&' {

    display Display.%etDisplay&t+is';

    Form form ne, Form&-Calculator-';

  • 8/18/2019 Design an Application Program for Mobile Phones (1)

    2/5

    form.append&- ello everybody-';

    item ne, $trin%Item&-/esult-" --';

    input! ne, extField&-First 0umber1-" --" 23" extField.04M5/IC';

    input# ne, extField&-$econd 0umber-" --" 23" extField.04M5/IC';

    form.append&input!';

    form.append&input#';

    add ne, Command&-)ddition-" Command.67" !';

    sub ne, Command&-$ubtraction-" Command.67" !';

    mul ne, Command&-Multiplication-" Command.67" !';

    div ne, Command&-Division-" Command.67" !'; form.addCommand&add';

    form.addCommand&sub';

    form.addCommand&mul';

    form.addCommand&div';

    form.append&item';

    form.setCommandListener&t+is';

    display.setCurrent&form';

    (

    public void pause)pp&' { (

    public void destroy)pp&boolean uncondn' {

    notifyDestroyed&';

    (

    private void calculate&'

    {int one Inte%er.parseInt&input!.%et$trin%&'';

    int t,o Inte%er.parseInt&input#.%et$trin%&'';

    int result one8t,o;

  • 8/18/2019 Design an Application Program for Mobile Phones (1)

    3/5

    item.set ext& result 8 -- ';

    (

    private void calculate!&' {

    int one Inte%er.parseInt&input!.%et$trin%&'';

    int t,o Inte%er.parseInt&input#.%et$trin%&'';

    int result one 9 t,o;

    item.set ext&result 8 --';

    (

    private void calculate#&' { int one Inte%er.parseInt&input!.%et$trin%&'';

    int t,o Inte%er.parseInt&input#.%et$trin%&'';

    int result one * t,o;

    item.set ext&result 8 --';

    (

    private void calculate2&' {

    int one Inte%er.parseInt&input!.%et$trin%&'';

    int t,o Inte%er.parseInt&input#.%et$trin%&'';

    int result one : t,o;

    item.set ext&result 8 --';

    (

    public void command)ction&Command c" Displayable d'{

    $trin% label c.%etLabel&';

    if &label.e uals&-)ddition-'' {

    calculate&';

    (

  • 8/18/2019 Design an Application Program for Mobile Phones (1)

    4/5

    else if &label.e uals&-$ubtraction-'' {

    calculate!&';

    (

    else if &label.e uals&-Multiplication-''

    {

    calculate#&';

    form.append&- +e )ns,er is1-';

    (

    else if &label.e uals&-Division-''

    { calculate2&';

    form.append&- +e )ns,er is1-';

    (

    (

    (

    'utPut(

  • 8/18/2019 Design an Application Program for Mobile Phones (1)

    5/5

    Conclusion: