The feeling when I don't know what to do or where to go next!
I was kind of lost the last few weeks, where nothing appears good to me. I supposed to keep working on Java because that's what I was wanting to. But eventually everything seemed to be non-worthy. I need some refreshing I think.
I was reading this page today: http://www.cprogramming.com/whyc.html am I going back to C programming? Maybe
peace~
Programmer, psp/ds/pc & mmo gamer, pink hater & other stuff girl
Monday, May 23, 2011
Sunday, May 8, 2011
A new growing-up OMANI forum
It's a nice name =)
and very good forum as a new-starting one.
Give it a click:
http://www.om-gear.com/vb/index.php
peace =)
and very good forum as a new-starting one.
Give it a click:
http://www.om-gear.com/vb/index.php
peace =)
Wednesday, April 27, 2011
Monday, January 10, 2011
get Sum and Average program (Open Source)
Hi,
I've just finished writing this code, it's not a new idea but good and exciting one =P
here it is:
//@ Simple program to get the sum and average for a number of values grouped in an array <---
//@ Author: 'Liberty' <---
//@ Date: Monday, January 10 2011 12:40 AM <---
//@ ########################## <---
import javax.swing.JOptionPane;
public class getSumAndAverage {
public static void main (String args []) {
// declaring variables and arrays
int num, t, x=0, i=0, count=0;
Double [] nums={};
Double ave=0.0, sum=0.0;
String s, message;
String [] ss={};
JOptionPane pane=new JOptionPane();
while(x==0) {
s=pane.showInputDialog("Enter how many numbers you want to operate\n\n");
num=Integer.parseInt(s);
ss=new String[num];
nums=new Double[num]; // getting the amount of elements wanted to be operated on and setting num as the array elements number
do {
for (i=0; i<num; i++) {
count++;
ss[i]=pane.showInputDialog("Enter a number: \n\nsum= "+sum+"\naverage= "+ave);
nums[i]=Double.parseDouble(ss[i]);
sum+=nums[i];
ave=sum/count; // numbers are added one by one, sum and average are being evaluated
}
// final result after entering all the elements
message="sum and average of your numbers:";
pane.showMessageDialog(null,message+"\nSum : "+sum+"\nAverage : "+ave,"result",JOptionPane.INFORMATION_MESSAGE);
// giving the user options to perform other operations
if (i==num) {
t=pane.showConfirmDialog(null,"Do another opertion? (The same number of entries)\n\n'No' for different number of entries\n'Cancel' for exit","Another operation?",JOptionPane.INFORMATION_MESSAGE);
if (t==JOptionPane.YES_OPTION) {
i=0;
x=1;
sum=0.0;
ave=0.0;
count=0; // resetting variables to initial values
}
else if(t==JOptionPane.NO_OPTION) {
x=0;
i=0;
sum=0.0;
ave=0.0;
count=0;
}
else {
pane.showMessageDialog(null,"Thank You!");
System.exit(0);
}
}
} // closing bracket of do while
while (x==1);
} // end of while
} // end of main class
} // end of getSumAndAverage class
Amasi, I've written comments this time XD
people, wish me luck =P
peace & all good stuff =)
liberty~
I've just finished writing this code, it's not a new idea but good and exciting one =P
here it is:
//@ Simple program to get the sum and average for a number of values grouped in an array <---
//@ Author: 'Liberty' <---
//@ Date: Monday, January 10 2011 12:40 AM <---
//@ ########################## <---
import javax.swing.JOptionPane;
public class getSumAndAverage {
public static void main (String args []) {
// declaring variables and arrays
int num, t, x=0, i=0, count=0;
Double [] nums={};
Double ave=0.0, sum=0.0;
String s, message;
String [] ss={};
JOptionPane pane=new JOptionPane();
while(x==0) {
s=pane.showInputDialog("Enter how many numbers you want to operate\n\n");
num=Integer.parseInt(s);
ss=new String[num];
nums=new Double[num]; // getting the amount of elements wanted to be operated on and setting num as the array elements number
do {
for (i=0; i<num; i++) {
count++;
ss[i]=pane.showInputDialog("Enter a number: \n\nsum= "+sum+"\naverage= "+ave);
nums[i]=Double.parseDouble(ss[i]);
sum+=nums[i];
ave=sum/count; // numbers are added one by one, sum and average are being evaluated
}
// final result after entering all the elements
message="sum and average of your numbers:";
pane.showMessageDialog(null,message+"\nSum : "+sum+"\nAverage : "+ave,"result",JOptionPane.INFORMATION_MESSAGE);
// giving the user options to perform other operations
if (i==num) {
t=pane.showConfirmDialog(null,"Do another opertion? (The same number of entries)\n\n'No' for different number of entries\n'Cancel' for exit","Another operation?",JOptionPane.INFORMATION_MESSAGE);
if (t==JOptionPane.YES_OPTION) {
i=0;
x=1;
sum=0.0;
ave=0.0;
count=0; // resetting variables to initial values
}
else if(t==JOptionPane.NO_OPTION) {
x=0;
i=0;
sum=0.0;
ave=0.0;
count=0;
}
else {
pane.showMessageDialog(null,"Thank You!");
System.exit(0);
}
}
} // closing bracket of do while
while (x==1);
} // end of while
} // end of main class
} // end of getSumAndAverage class
Amasi, I've written comments this time XD
people, wish me luck =P
peace & all good stuff =)
liberty~
Wednesday, January 5, 2011
the freaking exams
I hate when students get out of mind then. The 'Paper Hall' is a sad story :<
Wednesday, December 29, 2010
Aliens in the attic
Have you seen 'Aliens in the attic' movie?
such a great movie.
genre: adventure, science fiction, fantasy
few words of the movie:
Aliens, do they really exist? In the attic of the Pearson's family, Tom Pearson and his cousin Jake Pearson were up to fix the satellite broken accidentally by the aliens when a strange force sent them from the galaxy to the earth. Tom and Jake had their first fight with those aliens after they found that satellite was incredibly broken into pieces that cannot be fixed back together.
CAST
Tom Pearson
15 year old, math and technology genius. He made his grades in purpose go down. He hates Ricky (his sister's boyfriend) and took revenge by controlling him by the aliens' mind device.
Jake Pearson
Tom's cousin. The cool boy. He has an irrational dad and so is he. He made Tom to shoot Ricky by his gun. Yea his dad buys him such dangerous toys XD.
Hannah Pearson
7 year old girl. A member of the team. She made a friendship relation with a kind intruder. Sparks was the only non-threatening alien. Hannah tried to tell her dad about the aliens but Tom stopped her so then they pretended they were playing acting a video game characters.
Art & Lee Pearson
The twins Art and Lee are video games geeks. Unlike their brother Jake. They are quiet and smart. When first Ricky was under the aliens device control, they were like experts in controlling and using the device. It was like one of the video games they play on a game boy or whatever console.
Final thoughts:
great and funny movie. I recommend it for family gathering and every one ^^
peace and all good stuff
liberty ~
such a great movie.
genre: adventure, science fiction, fantasy
few words of the movie:
Aliens, do they really exist? In the attic of the Pearson's family, Tom Pearson and his cousin Jake Pearson were up to fix the satellite broken accidentally by the aliens when a strange force sent them from the galaxy to the earth. Tom and Jake had their first fight with those aliens after they found that satellite was incredibly broken into pieces that cannot be fixed back together.
CAST
Tom Pearson
![]() |
Carter Jenkins |
![]() |
Austin Butler |
Tom's cousin. The cool boy. He has an irrational dad and so is he. He made Tom to shoot Ricky by his gun. Yea his dad buys him such dangerous toys XD.
Hannah Pearson
![]() |
Ashley Boettcher |
![]() |
Henri Young and Regan Young |
The twins Art and Lee are video games geeks. Unlike their brother Jake. They are quiet and smart. When first Ricky was under the aliens device control, they were like experts in controlling and using the device. It was like one of the video games they play on a game boy or whatever console.
Final thoughts:
great and funny movie. I recommend it for family gathering and every one ^^
peace and all good stuff
liberty ~
Sunday, December 19, 2010
Creating Frames [Java Tutorial]
This tutorial was completely written by ME
||..~
The tutorial will be talking about GUI (Graphical User Interface) in java programming language. we all know that java is a OOP language. it means that we can design interfaces for the software we develop, so that the user could interact much easily with it. That's what graphical interfaces aimed to.
let's write a code to show a window, or a FRAME as we call it in Java, and see how the code will look like:
now we've already created our frame.
let's take it line by line:
import javax.swing.*;
this line is concerned for calling the package (javax.swing) which contains the JFrame component. simply, the frame cannot be created without including this package.
public class JFrameTest {
creating the class and name it as JFrameTest
public static void main (String [] args) {
this line is understood perfectly. If you are already taking tuts on GUI then it's probably not needed to explain.
JFrame f = new JFrame();
Here comes creating the frame and give it the name of f .
JFrame : the class name
f : creating the object (frame)
new : key word used for creating the frame which we gave f as the name of it .
JFrame : the constructor -followed by ' () ' and a ' ; ' , which has to be named the same as the class name .
and the last two lines are the closing brackets for JFrameTest and main classes.
||..~
if you run the code, nothing will show up. Because the frame is hidden and need to be visible. in this case, we need to set some attributes to the frame, at lease to make it visible.
so what we do?
look at the following:
(note: java is case sensitive. keep that in mind)
||..~
and that's all i guess. I don't know how I was doing. just hoping I covered everything well and hope my words make you get the basic idea .
*comments will be very welcome*
wish you peace, and all good stuff =)
liberty~
||..~
The tutorial will be talking about GUI (Graphical User Interface) in java programming language. we all know that java is a OOP language. it means that we can design interfaces for the software we develop, so that the user could interact much easily with it. That's what graphical interfaces aimed to.
let's write a code to show a window, or a FRAME as we call it in Java, and see how the code will look like:
import javax.swing.*;
public class JFrameTest {
public static void main (String [] args) {
JFrame f = new JFrame();
}
}
now we've already created our frame.
let's take it line by line:
import javax.swing.*;
this line is concerned for calling the package (javax.swing) which contains the JFrame component. simply, the frame cannot be created without including this package.
public class JFrameTest {
creating the class and name it as JFrameTest
public static void main (String [] args) {
this line is understood perfectly. If you are already taking tuts on GUI then it's probably not needed to explain.
JFrame f = new JFrame();
Here comes creating the frame and give it the name of f .
JFrame : the class name
f : creating the object (frame)
new : key word used for creating the frame which we gave f as the name of it .
JFrame : the constructor -followed by ' () ' and a ' ; ' , which has to be named the same as the class name .
and the last two lines are the closing brackets for JFrameTest and main classes.
||..~
if you run the code, nothing will show up. Because the frame is hidden and need to be visible. in this case, we need to set some attributes to the frame, at lease to make it visible.
so what we do?
look at the following:
import javax.swing.*;
public class JFrameTest {
public static void main (String [] args) {
JFrame f = new JFrame();
f.setVisible(true);
}
}
One line was added.
f.setVisible(true);
so this is the code responsible for making the frame VISIBLE
(the object name) f [dot] (the method) setVisible ([the boolean value] true ) in between the brackets ()
of course we don't forget the semi colon ;
||..~
Now let's add some other features to our frame .
Here goes the code :
3 more things were added. let's pick them up one by one .
First one was giving the frame a title : "Testing the frame"
we mentioned it in between the brackets in the same line of creating the frame. this looks simple. note that title has to be in between Double Quotes " "
Next thing
f.setSize(300,200);
setting the size of the frame by adding the arguments in between the brackets (WIDTH , HEIGHT);
we set 300 as the width, 200 as the height.
Last one
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this is a very useful line. well, it is a must in every frame we create. (may be some exceptions in higher levels)
this line is used for terminating the program. if we click on the (x) button, the program will still running, even though the frame disappears , the operation will still ON.
so we should include that code to stop the program when wanted to.
(frame name) f [dot] (method name, which is.. ) setDefaultCloseOperation (in between the brackets) we call the class name which is JFrame [dot] (the method) CLOSE_ON_EXIT
and remember all the time, the semi colon ;
f.setVisible(true);
so this is the code responsible for making the frame VISIBLE
(the object name) f [dot] (the method) setVisible ([the boolean value] true ) in between the brackets ()
of course we don't forget the semi colon ;
||..~
Now let's add some other features to our frame .
Here goes the code :
import javax.swing.*;
public class JFrameTest {
public static void main (String [] args) {
JFrame f = new JFrame("Testing the Frame");
f.setVisible(true);
f.setSize(300,200);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
3 more things were added. let's pick them up one by one .
First one was giving the frame a title : "Testing the frame"
we mentioned it in between the brackets in the same line of creating the frame. this looks simple. note that title has to be in between Double Quotes " "
Next thing
f.setSize(300,200);
setting the size of the frame by adding the arguments in between the brackets (WIDTH , HEIGHT);
we set 300 as the width, 200 as the height.
Last one
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this is a very useful line. well, it is a must in every frame we create. (may be some exceptions in higher levels)
this line is used for terminating the program. if we click on the (x) button, the program will still running, even though the frame disappears , the operation will still ON.
so we should include that code to stop the program when wanted to.
(frame name) f [dot] (method name, which is.. ) setDefaultCloseOperation (in between the brackets) we call the class name which is JFrame [dot] (the method) CLOSE_ON_EXIT
and remember all the time, the semi colon ;
(note: java is case sensitive. keep that in mind)
||..~
and that's all i guess. I don't know how I was doing. just hoping I covered everything well and hope my words make you get the basic idea .
*comments will be very welcome*
wish you peace, and all good stuff =)
liberty~
Subscribe to:
Posts (Atom)