About:
Anyone can download and examin. This is free educational purpose program written in JDK9 (jdk9.openjdk ). You can help me by buying its PRO version which is capable to calculate GST also enriched with features.
Screenshot of the free Program --
Here is its code :
/* A very simple calculator by Saurav Goswami <krishnasut@gmail.com>
* this is for Educational Purpose
* you can download and share data
* requirement - JDK9 and above
*/
import java.awt.* ;
import javax.swing.* ;
import java.awt.event.* ;
public class jcal {
public static JFrame win ;
public static JTextField tx ;
public static JButton btplus ;
public static JButton btminus ;
public static JButton btdiv ;
public static JButton btmul ;
public static JButton bteq ;
public static JButton btcls ;
public static JButton btb ;
public static JButton bta ;
public static JButton btc ;
public static JButton btd ;
public static JButton bte ;
public static JButton btf ;
public static JButton btg ;
public static JButton bth ;
public static JButton bti ;
public static JButton btj ;
public static JButton btTobin ;
public static JButton btTodec ;
public static String num ;
public static String operator ;
public static int ans ;
public static void main(String args[]) {
num="" ;
win = new JFrame("") ;
win.setTitle("GANAK") ;
win.setSize(500 , 200 ) ;
//adding JTextField
tx = new JTextField("", 20 ) ;
Font f = new Font("mono" , Font.BOLD , 20) ;
tx.setFont(f ) ;
btplus = new JButton("+") ;
btplus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ee) {
num = num + "," ;
tx.setText(num) ;
operator="+" ;
}
}) ;
bta = new JButton("0") ;
bta.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ee) {
num = num + "0" ;
tx.setText(num) ;
}
}) ;
btb = new JButton("1") ;
btb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ee) {
num = num + "1" ;
tx.setText(num) ;
}
}) ;
btc = new JButton("2") ;
btc.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ee) {
num = num + "2" ;
tx.setText(num) ;
}
}) ;
btd = new JButton("3") ;
btd.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ee) {
num = num + "3" ;
tx.setText(num) ;
}
}) ;
bte = new JButton("4") ;
bte.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ee) {
num = num + "4" ;
tx.setText(num) ;
}
}) ;
btf = new JButton("5") ;
btf.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ee) {
num = num + "5" ;
tx.setText(num) ;
}
}) ;
btg = new JButton("6") ;
btg.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ee) {
num = num + "6" ;
tx.setText(num) ;
}
}) ;
bth = new JButton("7") ;
bth.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ee) {
num = num + "7" ;
tx.setText(num) ;
}
}) ;
bti = new JButton("8") ;
bti.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ee) {
num = num + "8" ;
tx.setText(num) ;
}
}) ;
btj = new JButton("9") ;
btj.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ee) {
num = num + "9" ;
tx.setText(num) ;
}
}) ;
btminus = new JButton("-") ;
btminus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ee) {
num = num + "," ;
tx.setText(num) ;
operator="-" ;
}
}) ;
btmul = new JButton("*") ;
btmul.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ee) {
num = num + "," ;
tx.setText(num) ;
operator="x" ;
}
}) ;
btdiv = new JButton("/") ;
btdiv.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ee) {
num = num + "," ;
tx.setText(num) ;
}
}) ;
bteq = new JButton("=") ;
bteq.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ee) {
System.out.println(num) ;
String arr[] = num.split(",") ;
int ln = arr.length ;
if (operator.equals("+") ) {
//int ans = Integer.parseInt(arr[0]) + Integer.parseInt(arr[1]) ;
for (int f=0 ; f < ln ; f++) {
ans = ans+ Integer.parseInt(arr[f]) ;
}
tx.setText(ans+"") ;
num="" ;
ans=0 ;
}
if (operator.equals("-") ) {
int ans = Integer.parseInt(arr[0]) - Integer.parseInt(arr[1]) ;
tx.setText(ans+"") ;
num="" ;
ans=0 ;
}
if (operator.equals("x") ) {
ans=1 ;
//int ans = Integer.parseInt(arr[0]) * Integer.parseInt(arr[1]) ;
for (int f=0 ; f < ln ; f++) {
ans = ans* Integer.parseInt(arr[f]) ;
}
tx.setText(ans+"") ;
num="" ;
ans=0 ;
}
if (operator.equals("/") ) {
int ans = Integer.parseInt(arr[0]) / Integer.parseInt(arr[1]) ;
tx.setText(ans+"") ;
num="" ;
ans=0 ;
}
}//
}) ;
btcls = new JButton("CE") ;
btcls.setBackground(Color.ORANGE) ;
btcls.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ee) {
tx.setText("") ;
num="" ;
ans=0 ;
}
}) ;
btTobin = new JButton("DEC2BIN") ;
btTobin.setBackground(Color.GREEN) ;
btTobin.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ee) {
num = tx.getText() ;
ans = Integer.parseInt(num) ;
num = Integer.toBinaryString(ans);
tx.setText(num + " ( BINARY )") ;
num="" ;
}
});
Container cc = new Container() ;
cc.setLayout(new FlowLayout()) ;
cc.add(tx) ;
Container gg = new Container() ;
gg.setLayout(new FlowLayout()) ;
Container pp = new Container() ;
pp.setLayout(new FlowLayout()) ;
Container kk = new Container() ;
kk.setLayout(new FlowLayout()) ;
gg.add(bta) ;
gg.add(btb) ;
gg.add(btc) ;
gg.add(btd) ;
gg.add(bte) ;
kk.add(btf) ;
kk.add(btg) ;
kk.add(bth) ;
kk.add(bti) ;
kk.add(btj) ;;
pp.add(btplus) ;
pp.add(btminus) ;
pp.add(btmul) ;
pp.add(btdiv) ;
pp.add(bteq) ;
pp.add(btcls) ;
pp.add(btTobin) ;
Container mm = new Container() ;
mm.setLayout(new BoxLayout(mm , BoxLayout.Y_AXIS)) ;
mm.add(cc) ;
mm.add(gg) ;
mm.add(kk) ;
mm.add(pp) ;
win.add(mm) ;
win.setVisible(true) ;
win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) ;
}}
This free version is limited and very simple. Please buy its pro version to help support me.