You are on page 1of 50

M.C.A.

SEMESTER-V

WIRELESS TECHNOLOGY AND MOBILE


COMPUTING

(Journal)

PCP CENTER: CKT,PANVEL

University of Mumbai

Institute of Distance and Open Learning (IDOL)

Dr. Shankardayal Sharma bhavan, Vidyanagari, Santacruz(E)

University of Mumbai

Institute of Distance and Open Learning (IDOL)


Dr. Shankardayal Sharma bhavan, Vidyanagari, Santacruz(E)

PCP CENTER: CKT,PANVEL

Certificate
This is to certify that ________________________ of T.Y. M.C.A. Semester-V has completed
the specified term work in the subject of WIRELESS TECHNOLOGY AND MOBILE
COMPUTING satisfactorily within this institute as laid down by University of Mumbai during
the academic year 2016-2017

Staff Member Incharge

MCA Co-ordinator
(Prof. Anjali Kulkarni)

Examiner

University of Mumbai

Institute of Distance and Open Learning (IDOL)


INDEX
Sr. No

Practical Description

Write a program in J2ME to perform the following tasks:


A] Draw a text box on the device screen.
B] Change the background colour of the device screen.
C] Change the colour of the text.
D] Change the font style and font size of the displayed text.
Write a program in J2ME to perform the simple calculator
operations such as
a. Addition
b. Subtraction
c. Multiplication
d. Division

Page No.

Write a program in J2ME to create a simple Quiz which content


3 to 4 questions and also display the score.

13

Write a program in J2ME to create a currency converter and


also display the result.

19

5.

Write a program in J2ME to generate a calendar.

Write a program in J2ME to demonstrate simple animation


through snake movement

Write a program in J2ME to create a simple database application


with an address book with the following operations:
a. Insert
b. Delete
c. Update
d. Retrieve
Develop a simple website using XHTML

Develop a simple website using WML

10

File transfer between Laptop & Mobile phone using Bluetooth

22
24
28

35
40
47

Date

Sign

Program in J2ME to perform the following tasks:


Code:
Write a program in J2ME to perform the following tasks:
A] Draw a text box on the device screen.
ColorCanvas.java
B] Change the background colour of the device screen.
C] Change the colour of the text.
import
D] Change the font style and font size of the displayed text.
javax.microedition.lcdui.*;
import javax.microedition.media.*;
import java.io.*;
public class ColorCanvas extends Canvas implements CommandListener
{
private int i;
private Display display;
private int width, height;
String str2;
int j=1,bcol,fcol,sty;
private Command background = new Command("BACKGROUND",Command.SCREEN,1);
private Command textcolor = new Command("TEXTCOLOR",Command.SCREEN,1);
private Command fontstyle = new Command("CHANGE FONTSTYLE",Command.SCREEN,1);
private Command fontsize = new Command("CHANGE FONTSIZE", Command.SCREEN,1);
private Command change=new Command("CHANGE",Command.SCREEN,1);
static java.util.Random random = new java.util.Random();
public ColorCanvas(Display d,String str)
{
display = d;
str2= str;
this.addCommand(background);
this.addCommand(textcolor);
this.addCommand(fontstyle);
this.addCommand(fontsize);
setCommandListener(this);
bcol=random.nextInt()>>>1;
fcol=random.nextInt()>>>1;
repaint();
}
protected void paint(Graphics g)
{
width = getWidth();
height = getHeight();
g.setColor(bcol);

g.fillRect(0,0, width, height);


g.setColor(fcol);
g.drawString(str2,4,4,Graphics.TOP|Graphics.LEFT);
System.out.println("Case : "+i);
switch(i)
{
case 1:
bcol=random.nextInt()>>>1;
g.setColor(bcol);
g.fillRect(0,0,width,height);
g.setColor(fcol);
g.drawString(str2,4,4,Graphics.TOP
|Graphics.LEFT);
break;
case 2:
g.setColor(bcol);
g.fillRect(0,0,width,height);
fcol=random.nextInt()>>>1;
g.setColor(fcol);g.drawString(str2,4,4,Graphics.TOP|Graphics.LEFT);
break;
case 3:
g.setColor(bcol);
g.fillRect(0,0,width,height);
g.setFont(Font.getFont(Font.FACE_MONOSPACE,Font.STYLE_ITALIC,Font.SIZE_SMALL));
sty=0;
g.setColor(fcol);
g.drawString(str2,4,4,Graphics.TOP|Graphics.LEFT);
break;
case 4:
g.setColor(bcol);
g.fillRect(0,0,width,height);
g.setFont(Font.getFont(Font.FACE_MONOSPACE,Font.STYLE_PLAIN,Font.SIZE_SMALL));
sty=1;
g.setColor(fcol);
g.drawString(str2,4,4,Graphics.TOP|Graphics.LEFT);
break;
case 5:
g.setColor(bcol);

g.fillRect(0,0,width,height);
g.setFont(Font.getFont(Font.FACE_MONOSPACE,Font.STYLE_ITALIC,Font.SIZE_SMALL));
g.setColor(fcol);
g.drawString(str2,4,4,Graphics.TOP|Graphics.LEFT);
break;
case 6:
g.setColor(bcol);
g.fillRect(0,0,width,height);
g.setFont(Font.getFont(Font.FACE_MONOSPACE,Font.STYLE_ITALIC,Font.SIZE_LARGE));
g.setColor(fcol);
g.drawString(str2,4,4,Graphics.TOP|Graphics.LEFT);
break;
case 7:
g.setColor(bcol);
g.fillRect(0,0,width,height);
g.setFont(Font.getFont(Font.FACE_MONOSPACE,Font.STYLE_PLAIN,Font.SIZE_SMALL));
g.setColor(fcol);
g.drawString(str2,4,4,Graphics.TOP|Graphics.LEFT);
break;
case 8:
g.setColor(bcol);
g.fillRect(0,0,width,height);
g.setFont(Font.getFont(Font.FACE_MONOSPACE,Font.STYLE_PLAIN,Font.SIZE_LARGE));
g.setColor(fcol);
g.drawString(str2,4,4,Graphics.TOP|Graphics.LEFT);
break;
default:
break;
}
}
public void commandAction(Command c, Displayable d)
{
if (c==background)
{
i=1;
repaint();

}
else if(c==textcolor)
{
i=2;
repaint();
}
else if(c==fontstyle)
{
if(j==1)
{
i=3;
sty=0;
j=0;
}
else
{
j=1;
sty=1;
i=4;
}
repaint();
}
else if(c==fontsize)
{
if(j==1 && sty==1)
{
i=5;
sty=0;
}
else if(j==1 && sty==0)
{
i=6;
sty=1;
}
else if(j==0 && sty==1)
{
i=7;
sty=0;
}
else if(j==0 && sty==0)
{
i=8;
sty=1;
}

}
}
public void pauseApp()
{}
public void destroyApp(boolean unconditional)
{}
}
ColorDemo.java
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
import java.util.*;
public class ColorDemo extends MIDlet implements CommandListener
{
Command cmdExit,cmdDisp;
TextField txtFld;
Form frm;
Display disp;
ColorCanvas cc;
public void startApp()
{
disp = Display.getDisplay(this);
frm = new Form("Text Demo");
disp.setCurrent(frm);
frm.setCommandListener(this);
cmdExit=new Command("Exit",Command.EXIT,1);
frm.addCommand(cmdExit);
cmdDisp=new Command("Display",Command.SCREEN,1);
frm.addCommand(cmdDisp);
txtFld=new TextField("","",100,TextField.ANY);
frm.append(txtFld);
}
public void pauseApp()
{
}

public void destroyApp(boolean flag)


{
notifyDestroyed();
}
public void commandAction(Command c,Displayable d)
{
if(c==cmdExit)
{
destroyApp(true);
}
if(c==cmdDisp)
{
cc = new ColorCanvas(disp,txtFld.getString());
disp.setCurrent(cc);
}
}
}

Output:

Write a program in J2ME to perform the simple calculator operations such as


e. Addition
f. Subtraction
g. Multiplication
h. Division
Code :
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class Calc extends MIDlet implements CommandListener
{
Display disp;
TextField tf1,tf2,tf3;
Form form;
Command add,sub,mul,div,mod,exit;
public Calc()
{
disp=Display.getDisplay(this);
form=new Form("Operation on two numbers");
tf1=new TextField("Firstno.","0",30,TextField.ANY);
tf2=new TextField("Secondno.","0",30,TextField.ANY);
tf3=new TextField("Result","0",30,TextField.ANY);
form.append(tf1);
form.append(tf2);
form.append(tf3);
add=new Command("add",Command.SCREEN,1);
sub=new Command("sub",Command.SCREEN,1);
mul=new Command("mul",Command.SCREEN,1);
div=new Command("div",Command.SCREEN,1);
mod=new Command("mod",Command.SCREEN,1);
exit=new Command("exit",Command.EXIT,1);
form.addCommand(add);
form.addCommand(sub);
form.addCommand(mul);
form.addCommand(div);
form.addCommand(mod);
form.addCommand(exit);
form.setCommandListener(this);
}

public void startApp()


{
disp.setCurrent(form);
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}
public void commandAction(Command c,Displayable d)
{
if(c==add)
{
int a=Integer.parseInt(tf1.getString());
int b=Integer.parseInt(tf2.getString());
int c1=a+b;
tf3.setString(String.valueOf(c1));
}
if(c==sub)
{
int a=Integer.parseInt(tf1.getString());
int b=Integer.parseInt(tf2.getString());
int c1=a-b;
tf3.setString(String.valueOf(c1));
}
if(c==mul)
{
int a=Integer.parseInt(tf1.getString());
int b=Integer.parseInt(tf2.getString());
int c1=a*b;
tf3.setString(String.valueOf(c1));
}
if(c==div)
{
int a=Integer.parseInt(tf1.getString());
int b=Integer.parseInt(tf2.getString());
if(b==0)
tf3.setString("Divisor cannot be zero");
else
{
int c1=a/b;
tf3.setString(String.valueOf(c1));
}

}
if(c==mod)
{
int a=Integer.parseInt(tf1.getString());
int b=Integer.parseInt(tf2.getString());
if(b==0)
tf3.setString("Divisor cant be zero");
else
{
int c1=a%b;
tf3.setString(String.valueOf(c1));
}
}
if(c==exit)
{
destroyApp(false);
notifyDestroyed();
}

}
}

Output:

Write a program in J2ME to create a simple Quiz which content 3 to 4 questions and also display
the score.
Code:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.lang.*;
public class QuizDemo extends MIDlet implements CommandListener, ItemStateListener
{
private Display disp;
private Form form1,form2,form3,form4;
private Command exit,next1,next2,next3,submit;
private TextBox msg;
private Item selection;
private ChoiceGroup radiobuttons,rdb2,rdb3,rdb4;
StringItem ms1,ms2,ms3,ms4;
private int defaultIndex;
private int radioButtonIndex;
int flag=1;
public QuizDemo()
{
disp=Display.getDisplay(this);
ms1=new StringItem(null,"which following city is capital of India?");
radiobuttons=new ChoiceGroup("Select your answer",Choice.EXCLUSIVE);
radiobuttons.append("Bangalore",null);
radiobuttons.append("Delhi",null);
radiobuttons.append("Mumbai",null);
radiobuttons.append ("pune",null);
ms2=new StringItem(null,"which foilowing city is capital of Japan?");
rdb2=new ChoiceGroup("Select your answer",Choice.EXCLUSIVE);
rdb2.append("ya ka nua",null);
rdb2.append("Bijieng",null);
rdb2.append("Tokiyo",null);
rdb2.append("ku do su",null);
ms3=new StringItem(null,"which foilowing city is capital of UK?");
rdb3=new ChoiceGroup("Select your answer",Choice.EXCLUSIVE);
rdb3.append("Amsterdam",null);
rdb3.append("London",null);
rdb3.append("New york",null);
rdb3.append("Mexico",null);
ms4=new StringItem(null,"Which following city is capital of Egypt?");
rdb4=new ChoiceGroup("Select your answer",Choice.EXCLUSIVE);

rdb4.append("peru",null);
rdb4.append("Rome",null);
rdb4.append("Kairo",null);
rdb4.append("Sydney",null);
form1=new Form("Question 1");
form1.append(ms1);
radioButtonIndex=form1.append(radiobuttons);
form2=new Form("Question 2");
form2.append(ms2);
radioButtonIndex=form2.append(rdb2);
form3=new Form("QueStion 3");
form3.append(ms3);
radioButtonIndex=form3.append(rdb3);
form4=new Form("Question 4");
form4.append(ms4);
radioButtonIndex=form4.append(rdb4);
exit=new Command("Exit",Command.EXIT,1);
submit=new Command("Submit",Command.SCREEN,1);
next1=new Command("Next",Command.SCREEN,1);
next2=new Command("Next",Command.SCREEN,1);
next3=new Command("Next",Command.SCREEN,1);
msg=new TextBox("Message","Congrats",80,0);
form1.addCommand(next1);
form2.addCommand(next2);
form3.addCommand(next3);
form4.addCommand(submit);
form4.addCommand(exit);
form1.setCommandListener(this);
form2.setCommandListener(this);
form3.setCommandListener(this);
form4.setCommandListener(this);
form1.setItemStateListener(this);
form2.setItemStateListener(this);
form3.setItemStateListener(this);
form4.setItemStateListener(this);
}
public void startApp()
{
disp.setCurrent(form1);
}

public void pauseApp()


{
}
public void destroyApp(boolean unconditional)
{
}
public void itemStateChanged(Item item)
{
if(item==radiobuttons)
{
String ans=(radiobuttons.getString(radiobuttons.getSelectedIndex()));
if(ans.equals("Delhi"))
{
flag++;
}
}
if(item==rdb2)
{
String ans=(rdb2.getString(rdb2.getSelectedIndex()));
if(ans.equals("Tokiyo"))
{
flag++;
}
}
if(item==rdb3)
{
String ans=(rdb3.getString(rdb3.getSelectedIndex()));
if(ans.equals("London"))
{
flag++;
}
}
if(item==rdb4)
{
String ans=(rdb4.getString(rdb4.getSelectedIndex()));
if(ans.equals("kairo"))
{
flag++;
}
}
}

public void commandAction(Command com, Displayable disp1)


{
if(com==next1)
{
disp.setCurrent(form2);
}
if(com==next2)
{
disp.setCurrent(form3);
}
if(com==next3)
{
disp.setCurrent(form4);
}
if(com==exit)
{
destroyApp(false);
notifyDestroyed();
}
if(com==submit)
{
StringItem msg1=new StringItem(null,"You have Correct Answer "+
flag);
form4.append(msg1);
}
}
}

Output:

Write a program in J2ME to create a currency converter and also display


the result.
Code :
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class currency extends MIDlet implements CommandListener
{
private Display disp;
private Form f;
private TextField tb;
private TextField tb1;
private ChoiceGroup cg,cg1;
private Command resul;
private Command ans;
public currency()
{
tb=new TextField("","",20,TextField.NUMERIC);
tb1=new TextField("Result","Answer",10,TextField.ANY);
resul=new Command("Result",Command.SCREEN,1);
String[] str1 = { "pound", "Euro", "Dollar","yen" };
String[] str = {"Rupee"};
cg=new ChoiceGroup("",Choice.POPUP,str,null);
cg1 = new ChoiceGroup("",Choice.POPUP,str1,null);
f = new Form("Currency Convertor");
f.append(cg);
f.append(tb);
f.append(cg1);
f.append(tb1);
f.addCommand(resul);
f.setCommandListener(this);
}
public void startApp()
{
disp=Display.getDisplay(this);
disp.setCurrent(f);
}
public void pauseApp()
{

}
public void destroyApp(boolean unconditional)
{
}
public void commandAction(Command c, Displayable s)
{
int n,n1,res=0;
String res1;
n=cg1.getSelectedIndex();
n1=Integer.parseInt(tb.getString());
switch(n)
{
case 0:
res=n1/85;
break;
case 1:
res=n1/75;
break;
case 2:
res=n1/48;
break;
case 3:
res=n1*2;
break;
}
res1=Integer.toString(res);
System.out.println("first="+n1+"\nOperation
Index="+n+"\nResult="+res);
tb1.setString(res1);
}
}

Output :

Write a program in J2ME to generate a calendar.


Code:
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import java.util.Date;
import java.util.TimeZone;
public class CalenderMIDlet extends MIDlet{
private Form form;
private Display display;
private DateField calender;
private static final int DATE = 0;
public CalenderMIDlet(){
calender = new DateField("Date In:", DateField.DATE, TimeZone.getTimeZone("GMT"));
}
public void startApp(){
display = Display.getDisplay(this);
Form form = new Form("Calender");
form.append(calender);
display.setCurrent(form);
}
public void pauseApp(){}
public void destroyApp(boolean destroy){
notifyDestroyed();
}
}

Output:

Write a program in J2ME to demonstrate simple animation through snake


movement.
Code:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class MySnake extends MIDlet implements CommandListener
{
DrawSnake ds;
Display dis;
public MySnake()
{
dis =Display.getDisplay(this);
ds=new DrawSnake();
}
public void startApp()
{
dis.setCurrent(ds);
}
public void commandAction(Command c, Displayable d)
{}
public void pauseApp()
{}
public void destroyApp(boolean unconditional)
{}
}
class DrawSnake extends Canvas implements Runnable, CommandListener
{
int x,y,dir;
Thread th;
Command quit;
public DrawSnake()
{
x=0;
y=0;
dir=0;
quit=new Command("Quit",Command.SCREEN,1);
addCommand(quit);
setCommandListener(this);
th=new Thread(this);
th.start();

}
public void commandAction(Command c,Displayable d)
{
if(c==quit)
{}
}
public void keyPressed(int cd)
{
switch(getGameAction(cd))
{
case Canvas.UP:
y-=5;
dir=1;
break;
case Canvas.DOWN:
y+=5;
dir=2;
break;
case Canvas.LEFT:
x-=5;
dir=3;
break;
case Canvas.RIGHT:
x+=5;
dir=4;
break;
}
}
public void run()
{
while(true)
{
if(dir==1)
y-=5;
else if(dir==2)
y+=5;
else if(dir==3)
x-=5;
else if(dir==4)
x+=5;
repaint();
try
{
th.sleep(500);

}
catch(Exception ee)
{
}
}
}
public void paint(Graphics g)
{
g.setColor(0x1F2F1F);
g.fillRect(x,y,10,10);
g.drawString("Milind Thorat",25,25,Graphics.TOP | Graphics.LEFT);
}
}

Output:

Write a program in J2ME to create a simple database application with an address book with the
following operations:
e.
f.
g.
h.

Insert
Delete
Update
Retrieve

Code:
import java.io.*;
import java.util.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.io.*;
public class MySQLConn extends MIDlet implements CommandListener
{
private String username;
private String url="http://localhost:8080/jj/getConnection";
private Display display;
private Command exit=new Command("EXIT", Command.EXIT,1);
private Command connect=new Command("Connect", Command.SCREEN,1);
private Form menu;
private TextField tb1;
private TextField tb2;
DBConn db;
public MySQLConn() throws Exception
{
display=Display.getDisplay(this);
}
public void startApp()
{
displayMenu();
}
public void displayMenu()
{
menu=new Form("Connect");
tb1=new TextField("Please input username:","",30,TextField.ANY);
tb2=new TextField("Please input password:","",30,TextField.PASSWORD);
menu.append(tb1);
menu.append(tb2);
menu.addCommand(exit);

menu.addCommand(connect);
menu.setCommandListener(this);
display.setCurrent(menu);
}
public void pauseApp()
{}
public void destroyApp(boolean unconditional)
{}
public void commandAction(Command command,Displayable screen)
{
if(command==exit)
{
destroyApp(false);
notifyDestroyed();
}
else if(command==connect)
{
db=new DBConn(this);
db.start();
db.connectDb(tb1.getString(),tb2.getString());
}
}
public class DBConn implements Runnable
{
MySQLConn midlet;
private Display display;
String db;
String user;
String pwd;
public DBConn(MySQLConn midlet)
{
this.midlet=midlet;
display=Display.getDisplay(midlet);
}
public void start()
{
Thread t=new Thread(this);
t.start();
}
public void run()
{
StringBuffer sb=new StringBuffer();
try

{
HttpConnection c=(HttpConnection) Connector.open(url);
c.setRequestProperty("User-Agent","Profile/MIDP-1.0,
Configuration/CLDC-1.0");
c.setRequestProperty("Content-Language","en-US");
c.setRequestMethod(HttpConnection.POST);
DataOutputStream os=(DataOutputStream)c.openDataOutputStream();
os.writeUTF(user.trim());
os.writeUTF(pwd.trim());
os.flush();
os.close();
DataInputStream is=(DataInputStream)c.openDataInputStream();
int ch;
sb=new StringBuffer();
while((ch=is.read())!=-1)
{
sb.append((char)ch);
}
showAlert(sb.toString());
is.close();
c.close();
}
catch(Exception e)
{
showAlert(e.getMessage());
}
}
public void connectDb(String user,String pwd)
{
this.user=user;
this.pwd=pwd;
}
private void showAlert(String err)
{
Alert a=new Alert("");
a.setString(err);
a.setTimeout(Alert.FOREVER);
display.setCurrent(a);
}
};
}

Servlet Code for JDBC Connection:


import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class getConnection extends HttpServlet
{
Connection conn;
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter out=response.getWriter();
DataInputStream in=new DataInputStream((InputStream)request.getInputStream());
String user=in.readUTF();
String pwd=in.readUTF();
System.out.println("received data is==>"+user+pwd);
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn=DriverManager.getConnection("jdbc:odbc:milu");
Statement stmt=conn.createStatement();
int i=stmt.executeUpdate("insert into Login Values('"+user+"','"+pwd+"')");
if(i!=0)
{
out.println("Hi, Milind, Data has Inserted Successfully");
}
else
{
out.println("iData is Not inserted");
}
}
catch(Exception e)
{
e.printStackTrace();
}
out.println("Your Name is: "+user+"\n Your Password is:"+pwd);
in.close();
out.close();
out.flush();

}
public void doget(HttpServletRequest request,HttpServletResponse response)
throws ServletException, IOException
{
doPost(request,response);
}
}

Output:

Develop a simple website using XHTML


Code:
Index.xhtml
<?xml version="1.0" encoding ="utf-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobite 1.0//EN"
"http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<htmI xmIns="http://www.w3.org/1999/xhtml">
<head>
<title>C Tutorial by Chetan</title>
</head>
<body>
<center> <img src="abc.gif" height="10" width="10" alt="Image cannot be displayed"/> </center>
<h1>Index</h1>
c is a programming language developed at AT & T's Bell Laboratories of USA in 1g72. It
was designed and written by Dennis Ritchie. C seems to be so popular because it is reliable,
simple and easy to use.
<ol>
<li> <a href="lesson1.xhtml">Getting Started </a> </li>
<li> <a href="lesson2.xhtml">Decision Control Structure </a> </li>
<li> <a href="lesson3.xhtml">Loop Control Structure </a> </li>
<li> <a href="lesson5.xhtml"> Case Control Structure </a> </li >
<li> <a href="lesson4.xhtml"> Functions</a> </li>
<li> <a href="lesson6.xhtml"> pointers</a> </li>
<li> <a href="lessonT,xhtml"> Structures </a> </li>
<li> <a href="lesson8.xhtml"> Arrays </a> </li>
<li> <a href="lesson9.xhtml">puppetting On Strings</a> </li>
<li> <a href="lesson10.xhtml">Typecasting </a> </li>
<li> <a href="lesson11.xhtml">Command Line Arguments</a> </li>
</ol>
</body>
</html>
Lesson1.xhtml
<?xml version="1.0" encoding ="utf-8"?>
<!DOCTYPE html PUBLIC"-//WAPFORUM//DTD XHTML Mobile 1.O//EN"
"http://www.wapforum.org/DTD/xhtmI-mobile 10.dtd">
<htmI xmlns="http ://www.w3.org/1999/xhtml">
<head><title> Lesson 1 of C Tutorial</title></head>
<body>
<Center><h1>Getting Started</h1></center>

<h2>Hello World Program</h2>


commands that do "something". The main function is always called when the'program first
executes. From main, we can call other functions, whether they are written by uJor by others or
use built-in language features. To access the standard functions that comes with your compiler,
you need to include a header with the #include directive. What this does is effectively take
everything in the header and paste it into your program.
<pre class="example">
#include &lt;stdio.h&gt;
int main()
{
printf("Hello World \n Welcome to C programming");
return 0;
}
</pre>
Let's look at the elements of the program. The #include is a "preprocessor" directive that tells the
compiler to put code from the header called stdio,h into our program before actually creating the
executable. By including header files, you can gain access to many different library functions
like printf etc. The semicolon is part of the syntax of C. It tells the compiler that you are at the
end of a command, The next imporant line is int main0. This line tells the compiler that thereis a
function named main, and that the function returns an integer.The "curly braces" ({ and }) signal
the beginning and end of functions and othercode blocks. The printf function is the standard C
way of displaying output on the screen. The quotes tell the compiler that you want to output the
literal string as it is, The'\n'sequence is actually treated as a single character that stands for a
newline. Finally, at the end of the program, we return a value from main to the operating system
by using the return statement. This return value is important as it can be used to tell the operating
system whether our program succeeded or not. A return value of 0 means success. The final
brace closes off the function.
<h2>Using Variables</h2>
In C, input and data are stored in variables. There are several different types of variables; when
you tell the compiler you are declaring a variable, you must include the data type along with the
name of the variable. Several basic types include char, int, and float. Each type can store
different types of data, A variable of type char stores a single character, variables of type int
store integers (numbers without dectmal places), and variables of type float store numbers with
decimal places. Each of these variable types - char, int, and float - is each a keyword that you use
when you declare a variable. Before you can use a variable, you must tell the compiler about it
by declaring it and telling the compiler about what its "type" is. To declare a variable you use
the syntax &lt;variable type&gt; &lt;name of variable&gt;; For instance, a basic variable
declaration
might look like this:
<pre class="example">
int myVariable;
</pre>
<h2>Reading input</h2>

<pre class="example">
#include &lt;stdio. h&gt;
int main()
{
int number;
printf( "Please enter a number: " );
scanf( "70d", &number );
printf( "You entered o/od", number );
return 0;
}
</pre>
The #include and main function before; main must appear in every program you intend to run/
and the #include gives us access to printf as well as scanf. The io in stdio.h stands for
"lnput/output"; std just stands for "standard". The keyword int declares number to be an integer.
The printf function is udes to display strings and scanf function is used to receive input from the
user,
</br></br>
<a href="index.xhtml">HOME</a> &nbsp; &nbsp; &nbsp;<a href="lesson2.xhtml">NEXT</a>
</body>
</html>
Lesson3.xhtml
<?xml version="1,0" encoding ="utf-8"?>
<!DOCTYPE html PUBLIC"-//WAPFORUM//DTD XHTML Mobite 1.O//EN"
"http://www.wapforum.org/DTD/xhtml-mobile 10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title> Lesson 2 of C Tutorial</title></head>
<body>
<Center><h1>Decision Control Structure</h1></center>
<h2>If Syntax</h2>
The structure of an if statement is as follows:
<pre class="example">
if(condition)
{
// if condition is true then this block is executed
}
</pre>
Here is a simple example:
<pre class="example">
if( 5 &lt; 10 )
{
printf("Five is less than ten");
{

</Pre>
<h2>If with Else</h2>
Sometimes when the condition in an if statement evaluates to false, it would be nice to execute
some code instead of the code executed when the statement evaluates to true. The "else"
statement effectively says that whatever code after it (whether a single line or code between
brackets) is executed if the if statement is FALSE.
<pre class="example">
if(TRUE)
{
// if condition is true then this block is executed
}
else
{
// if condition is false then this block is executed
}
</pre>
<h2>Else lf</hz>
Another use of else is when there are multiple conditional statements that may all evaluate to
true, yet you want only one if statement's body to execute. You can use an "else if' statement
following an if statement and its body; that way, if the first statement is true, the "else if" will be
ignored, but if the if statement is false, it will then check the condition for the else if statement, If
the if statement was true the else statement will not be checked. It is possible to use numerous
else if statements to ensure that only one block of code is executed.
<pre class="example">
if(&lt;condition&gt;)
{// Execute these statements if &lt;condition&gt; is TRUE
else if(&lt;anothercondition&gt;)
{
// Execute these statements if &lt;another condition&gt; is TRUE and
// &lt;condition&gt; is FALSE
}
else
{
// Execute this statements if both the above conditions evaluates to false
}
</pre>
<br/>
<a href="index.html">HOME</a> &nbsp; &nbsp; &nbsp; <a href="lesson1.html">PREVIOUS</a>
&nbsp; &nbsp; &nbsp;
<a href="lesson3.html">NEXT</a>
</body>
</html>

Output:

Develop a simple website

using WML

Code: Main.wml
<!-Program to develop a
WML -->
<?xml version="1.0"?>
<!DOCTYPE wml
"-//WAPFORUM//DTD

"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card title="Anchor Tag">
<p> <anchor>Go to Login page <go href="form.wml"/> </anchor> </p>
</card>
</wml>
Output:

simple website using

PUBLIC
WML 1.1//EN"

Code: form.wml
<!-Program to develop a simple website using WML -->
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="card1" title="KJSIEIT">
<do type="accept" label="Answer">
<go href="#card2"/>
</do><br/>
<p>
<select name="name">
<option value="COMPS">COMPS</option>
<option value="EXTC">EXTC</option>
<option value="IT">IT</option>
</select>

<br/>
First name:<input type="text" name="firstname"/><br/>
Last name:<input type="text" name="lastname"/><br/>
Roll No:<input type="text" name="Rollno"/><br/>
</p>
<p> <anchor> Next page <go href="test.wml"/> </anchor> </p>
</card>
</wml>
Output:

Code: form.wml
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="one" >
<p> Username:<input type="text" name="use"/> <br/><br/>
Password:<input type="password" name="pwd"/>
</p>
<do type="login">
<go href="#two"/>
</do> </card>
<card id="two" >
<p> hello $(use) Your password is $(pwd) </p>
<do type="back">
<go href="#one"/>
</do>
<p> <anchor>Go to text page<go href="text.wml"/> </anchor> </p>

</card>
</wml>
Output:

Code: text.wml
<!-Program to develop a simple website using WML -->
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="card1" title="KJSIEIT">
<do type="accept" label="Answer">
<go href="#card2"/>
</do><br/>
<p>
<select name="name">
<option value="COMPS">COMPS</option>
<option value="EXTC">EXTC</option>
<option value="IT">IT</option>

</select>
<br/>
First name:<input type="text" name="firstname"/><br/>
Last name:<input type="text" name="lastname"/><br/>
Roll No:<input type="text" name="Rollno"/><br/>
</p>
<p> <anchor> Next page <go href="test.wml"/> </anchor> </p>
</card>
</wml>
Output:

Code: test.wml
<!-Program to develop a simple website using WML -->
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card>
<p>
<p> <anchor>Go to last page <go href="out.wml"/> </anchor> </p>
</p>
</card>
</wml>
Output:

Code: out.wml
<!-Program to develop a simple website using WML -->
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="card 1" title="Tutorial">
<do type= "accept" label="Answer">
<go href="#card2"/>
</do>
<p> <select name="name">
<option value="HTML">HTML Tutorial</option>
<option value="XML">XML Tutorial</option>
<option va lue="WAP">WAP Tutorial</option>
</select> </p>
</card>

<card id ="card2" title="Answer">


<p>You selected : $(name)</p>
</card>
</wml>
Output:

File transfer between Laptop & Mobile phone using Bluetooth


Instructions:
Things will need:

Bluetooth enabled PC
Bluetooth enabled cell Phone

Step 1: Enable Bluetooth on the PC.


To enable Bluetooth on the PC visit your control panel. we Should see an option for
Bluetooth devices. Select this option and make sure the technology is enabled. If you are
installing a USB module, we should be able to plug it in and use it right away. If not, it should
come with drivers to install (insert the disc, and install the software).

Step 2: Enable bluetooth on the cell phone


Each phone is different, but you should be able to go to a setting menu, and select Bluetooth.
There should be an option to enable Bluetooth on the phone. Enable it, and make sure the phone is
visible.
Step 3: Allow the PC to search for devices
It should find the cell phone. If not, we can try searching for the computer with the cell phone.
Many times, with the USB modules, they have trouble finding the cell, but the cell can find the computer,
The important part is that the devices connect, regardless of which device finds which.
Step 4: Approve the devices to connect
Sometimes, the devices will automatically connect, and we will be ready to go.. However, if this is
not the case, refer to step 5
Step 5: Enter any necessary security codes
If you do not know these codes, try the defaults, (1234, last 4 digits of your phone number, etc.).
Step 6:
Select the files on the computer that we want, and we should be able to right click and select
"send via bluetooth". Click this option, and let the files send.

Another way is with windows XP and Bluetooth enabled mobile


a) Setup on the Device
Step 1: On the device, Press Menu.
Step 2: Scroll to Connect. And press the scroll key.
Step 3: Scroll to Bluetooth and press the scroll key.
Step 4: Scroll to Bluetooth and press the scroll key till on is displayed.
Step 5: Scroll to My phone's visibility and press the scroll key till shown to all
Is displayed.

Step 6: Scroll to My phone's name and press the scroll key.


Step 7: Enter Nokia in the field provided and press Ok.
Step 8: Press Exit and End key to go back to main screen.
b) Setup on the Laptop
Step 1: On the laptop, click on Start.
Step 2: Select Control Panel.
Step 3: Select and click on Bluetooth Devices.
Step 4: click on Add. And a pop-up "Add Bluetooth Device wizard" would
Displayed.
Step 5: checked on "My device is set up and ready to be found" and press Next.
Step 6: Select on Nokia New device and press Next.
Step 7: Checked "Let me choose my own passkey" And enter an 8 to 16 digit
Passkey.
Step 8: Press Next..
Step 9: On your device, "Add to My Devices?" is displayed, press Yes'
Step 10: Enter the same 8 to 16 digit passkey that you have entered previously and
Press ok.
Step 11: Please wait while your laptop is installing the Bluetooth,
Step 12: Press Finish when the Completing the "Add Bluetooth Device Wizard" is
displayed.

You might also like