My Life and the world

World changes day by day!

Sunday, November 9, 2014

Java Program for Calculator using Applet

2 comments
Today I am going to present you java source code for calculator applet. This java applet program for calculator is GUI based with options of some simple operations like addition, subtraction, division and Multiplication. The Buttons of the operators and the number are being colored.


Here is the complete Java Program for Calculator using Applet


/*



*/
import java.awt.*;
import java.awt.event.*;

public class calculator extends java.applet.Applet implements ActionListener {
TextField txtTotal = new TextField("");
    Button button[] = new Button[10];
Button divide = new Button("/");
Button mult = new Button("*");
Button plus = new Button ("+");
Button minus = new Button("-");
Button isequalto = new Button("=");
Button clear = new Button("CA");
double num ,numtemp ;
int counter;
String strnum = "",strnumtemp = "" ;
String op = "";

public void operation() {
counter ++;
if (counter == 1) {
 numtemp = num;
 strnum = "";
 num = 0;
}else{
 if (op == "+") numtemp += num;
 else if (op == "-") numtemp -= num;
 else if (op == "*") numtemp = numtemp * num;
 else if (op == "/") numtemp = numtemp / num;
 strnumtemp = Double.toString(numtemp);
 txtTotal.setText(strnumtemp);
 strnum = "";
 num = 0;
}
}

public void init() {
setLayout(null);

plus.setBackground(Color.blue);
plus.setForeground(Color.white);
     minus.setBackground(Color.blue);
minus.setForeground(Color.white);
     divide.setBackground(Color.blue);
divide.setForeground(Color.white);
isequalto.setBackground(Color.blue);
isequalto.setForeground(Color.white);
mult.setBackground(Color.blue);
mult.setForeground(Color.white);
clear.setBackground(Color.blue);
clear.setForeground(Color.red);

for(int i = 0;i <= 9; i ++) {
button[i] = new Button(String.valueOf(i));
button[i].setBackground(Color.orange);
button[i].setForeground(Color.blue);
}

button[1].setBounds(0,53,67,53);
button[2].setBounds(67,53,67,53);
button[3].setBounds(134,53,67,53);
button[4].setBounds(0,106,67,53);
button[5].setBounds(67,106,67,53);
button[6].setBounds(134,106,67,53);
button[7].setBounds(0,159,67,53);
button[8].setBounds(67,159,67,53);
button[9].setBounds(134,159,67,53);

for (int i = 1;i <= 9; i ++) {
add(button[i]);
}

txtTotal.setBounds(0,0,200,53);
add(txtTotal);
plus.setBounds(0,212,67,53);
add(plus);
button[0].setBounds(67,212,67,53);
add(button[0]);
minus.setBounds(134,212,67,53);
add(minus);
divide.setBounds(134,264,67,53);
add(divide);
isequalto.setBounds(67,264,67,53);
add(isequalto);
mult.setBounds(0,264,67,53);
add(mult);
add(clear);
}

public void start() {
for(int i = 0;i <= 9; i ++) {
button[i].addActionListener(this);
}
plus.addActionListener(this);
minus.addActionListener(this);
divide.addActionListener(this);
mult.addActionListener(this);
isequalto.addActionListener(this);
clear.addActionListener(this);
}

public void stop() {
for(int i = 0;i <= 9; i ++) {
button[i].addActionListener(null);
}
plus.addActionListener(null);
minus.addActionListener(null);
divide.addActionListener(null);
mult.addActionListener(null);
isequalto.addActionListener(null);
clear.addActionListener(null);
}

public void actionPerformed(ActionEvent e) {
for(int i = 0;i <= 9; i++) {
if (e.getSource() == button[i]) {
  play(getCodeBase(),i + ".au");
  strnum += Integer.toString(i);
  txtTotal.setText(strnum);
  num = Double.valueOf(strnum).doubleValue();
}
}

        if (e.getSource() == plus) {
operation();
op = "+";
}

if (e.getSource() == minus) {
operation();
op = "-";
}

if (e.getSource() == divide) {
operation();
op = "/";
}

if (e.getSource() == mult) {
operation();
op = "*";
}

if (e.getSource() == isequalto) {
if (op == "+") numtemp += num;
else if (op == "-") numtemp -= num;
else if (op == "*") numtemp = numtemp * num;
else if (op == "/") numtemp = numtemp / num;

strnumtemp = Double.toString(numtemp);
txtTotal.setText(strnumtemp);
strnumtemp = "";
numtemp = 0;
strnum = "";
num = 0;
counter = 0;
}

if (e.getSource() == clear) {
txtTotal.setText("0");
strnumtemp = "";
numtemp = 0;
strnum = "";
num = 0;
counter = 0;
}
}
}

Saturday, November 1, 2014

ISLAMRELIGION.COM Promoting How to Convert to Islam online

3 comments
When I was working for one of my blog, I saw ad via my Google Adsense on the blog. The ad was very much surprising to me. I saw it first time and was very much amused with it. You can see the image below-

The whole story need time to get who is doing it and why they are doing it. I reached it a bit for you. How can one do like this, spreading the religion with an ad ? Is this wrong unlawful? If you reader have any idea post it in you comment. I don't have much to say here but I will show you some useful stuffs.

The Website link is  - http://www.islamreligion.com/ you can go and check it out all the stuffs.


About this domain - 

  • Domain Name: ISLAMRELIGION.COM
  • Creation Date: 1999-11-15 15:35:44
  • Registrar Registration Expiration Date: 2014-11-15 15:35:44
  • Reseller: MyDomain (mydomain-inc)
  • Registrant Name: Ibrahim Ali Abu-Harb
  • Registrant Organization: Ibrahim Ali Abu-Harb
  • Registrant Street: PO Box 343
  • Registrant City: Riyadh
  • Registrant State/Province: 
  • Registrant Postal Code: 11323
  • Registrant Country: SA
  • Registrant Phone: +966.14541065
  • Registrant Phone Ext: 
  • Registrant Fax: +966.14536842
  • Registrant Email: Email Masking Image@i-g.org
As you know this from Saudi Arabia and the person named Ibrahim Ali Abu-Harb has registered this domain and it is much older than I think, it started wayback in 1999 It's 15 year old nobody knows about it.

They are providing the one to one online chatting to help people convert to Islam.

I think they are doing over the world and now spreading the online presence in India as well. I would collect more information about it and post it here, meanwhile you can read my chatting with their one of the call center expert.