Now lets have some work with JAVA .an object oriented language..........after whole day............hard work got fully tired and now posting a simple n basic programme just typed now only..........in my netbeans which is open source software developed by sun java...........so lets check whether the number entered by the user is prime or not...just used some simple logical calculation
so here comes our design view
the source code given in the check button as follows.......
int a=Integer.parseInt(jTextField1.getText());
int c;
int b;
int d;
if(a==2){
jLabel1.setText("it is a prime number");}
if(a==0 || a==1){
jLabel1.setText("it is only a natural number");
}
for(int i=2;i<a;++i){
c=a%i;
d=a-1;
if(c==0){
jLabel1.setText("it is not a prime number");
break;
}
else {
if(c>0 && i==d){
jLabel1.setText("it is a prime number");
}
}
}
here again i have used looping................its fun to play with looping......u will be amazed to know that Facebook used looping in wishing happy birthday to all the users...............
looping is a basic thing....................so for beginner like me..its of great importance...because in my view new buddies can do any thing..
here another screen shot........................don't think that it is boring ...........it is all basic we will grow higher n higher.....step by step..
again i m repeating "EVERYONE SHOULD LEARN TO CODE BECAUSE IT TEACHES YOU HOW TO THINK"-Steve Jobs
now going to have some chats with my friend especially girls on facebook.............till then goodnight n have tight sleep......
so here comes our design view
the source code given in the check button as follows.......
int a=Integer.parseInt(jTextField1.getText());
int c;
int b;
int d;
if(a==2){
jLabel1.setText("it is a prime number");}
if(a==0 || a==1){
jLabel1.setText("it is only a natural number");
}
for(int i=2;i<a;++i){
c=a%i;
d=a-1;
if(c==0){
jLabel1.setText("it is not a prime number");
break;
}
else {
if(c>0 && i==d){
jLabel1.setText("it is a prime number");
}
}
}
here again i have used looping................its fun to play with looping......u will be amazed to know that Facebook used looping in wishing happy birthday to all the users...............
looping is a basic thing....................so for beginner like me..its of great importance...because in my view new buddies can do any thing..
here another screen shot........................don't think that it is boring ...........it is all basic we will grow higher n higher.....step by step..
again i m repeating "EVERYONE SHOULD LEARN TO CODE BECAUSE IT TEACHES YOU HOW TO THINK"-Steve Jobs
now going to have some chats with my friend especially girls on facebook.............till then goodnight n have tight sleep......
No comments:
Post a Comment