Source Code Kalkulator Sciencetific Java

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 50

Source Code kalkulator sciencetific Java Netbeans

//membuat class prioritasnya


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Stack;
public class Prioritas {
private Stack<Double> stackOfOperand;
private Stack<Character> stackOfOperator;
public Prioritas() {
stackOfOperator = new Stack<Character>();
stackOfOperand = new Stack<Double>();
}
public boolean isOperator(String token) {
return (token.equalsIgnoreCase(^) || token.equalsIgnoreCase(*) ||
token.equalsIgnoreCase(/) ||
token.equalsIgnoreCase(%) || token.equalsIgnoreCase(+) || token.equalsIgnoreCase(-) ||
token.equalsIgnoreCase(<) || token.equalsIgnoreCase(>) || token.equalsIgnoreCase(&)
||
token.equalsIgnoreCase(|) || token.equalsIgnoreCase(#));
}
public boolean isOperand(String token) {
//sudah menangani kasus bilangan negatif
return (!isOperator(token) && ((Character.isDigit(token.charAt(0))) || (token.charAt(0) ==
-)));
}
//mengembalikan prioritas operator saat evaluasi
public int skala_prioritas(char tanda) {
int skala;
switch (tanda) {
case ^:{
skala = 7;
break;
}
case *:{
skala = 6;
break;
}
case /:{

skala = 6;
break;
}
case %:{
skala = 6;
break;
}
case +:{
skala = 5;
break;
}
case -:{
skala = 5;
break;
}
case <:{
skala = 4;
break;
}
case >:{
skala = 4;
break;
}
case &:{
skala = 3;
break;
}
case #:{
skala = 2;
break;
}
case |:{
skala = 1;
break;
}
default:{
skala = 0;
break;
}
}
return skala;
}
public String convertToPostfix(String infixExp) throws Exception, PrioritasException {
StringTokenizer st = new StringTokenizer(infixExp);
String curToken = , postfixExp = ;
int nKurungBuka = 0, nKurungTutup = 0;
while(st.hasMoreTokens()) {

//mengambil token
curToken = st.nextToken();
if(isOperand(curToken)) {
//jika currentToken adalah operand, maka kembalikan sebagai ekspresi postfix
postfixExp = postfixExp + + (Double.parseDouble(curToken));
} else if(curToken.equals(()) {
//jika currentToken adalah kurung buka, maka push tanda kurung buka ke stack operator
Character tanda = new Character(();
stackOfOperator.push(tanda);
nKurungBuka++;
} else if(curToken.equals())) {
//jika currentToken adalah kurung tutup, maka pop stack operator sampai ketemu kurung
buka
while(((Character)stackOfOperator.peek()).charValue() != () {
postfixExp = postfixExp + + stackOfOperator.pop();
}
if (((Character)stackOfOperator.peek()).charValue() == ()
stackOfOperator.pop();
nKurungTutup++;
} else if(isOperator(curToken)) {
//jika currentToken adalah operator
if(stackOfOperator.isEmpty()) {
//stack operator masih kosong, maka push currentToken ke stack operator
Character tanda = new Character(curToken.charAt(0));
stackOfOperator.push(tanda);
} else {
/*
stack operator sudah ada isinya
ambil puncak stack, lalu bandingkan presedensinya dengan currentToken
jika precendence(puncak) > precedence(currentToken) maka pop stack
*/
Character tanda = new Character(curToken.charAt(0));
if (skala_prioritas(((Character)stackOfOperator.peek()).charValue()) > skala_prioritas(tanda))
{
postfixExp = postfixExp + + stackOfOperator.pop();
}
//push currentToken
stackOfOperator.push(tanda);
}
} else {
//ekspresi tidak valid
throw new PrioritasException(Syntax Error);
}
//System.out.println(bla + +postfixExp );
//bla++;
}
//ekspresi tidak valid
if(nKurungBuka != nKurungTutup)
throw new PrioritasException(Syntax Error);

//pop terus stack operator sampai kosong


while (!stackOfOperator.isEmpty()) {
postfixExp = postfixExp + + stackOfOperator.pop();
}
return postfixExp;
}
public double evaluate(String postfixExp) throws Exception {
StringTokenizer st = new StringTokenizer(postfixExp);
double skala;
String curToken = ;
while (st.hasMoreTokens()) {
//mengambil token
curToken = st.nextToken();
if(isOperand(curToken)) {
//jika currentToken adalah operand, maka push ke stack operand
Double opn = new Double(Double.parseDouble(curToken));
stackOfOperand.push(opn);
} else {
//jika currentToken adalah operator, maka evaluasi dua operan sebelumnya
double opn2 = ((Double)stackOfOperand.pop()).doubleValue();
double opn1 = ((Double)stackOfOperand.pop()).doubleValue();
double result = 0;
switch(curToken.charAt(0)) {
case ^:{
result = Math.pow(opn1, opn2);
break;
}
case *:{
result = opn1 * opn2;
break;
}
case %:{
result = opn1 % opn2;
break;
}
case /:{
result = opn1 / opn2;
break;
}
case -:{
result = opn1 opn2;
break;
}
case +:{
result = opn1 + opn2;
break;
}
case <:{

double bulat1= Math.round(opn1);


int x = (int)bulat1;
double bulat2= Math.round(opn2);
int y = (int)bulat2;
result = x << y;
double bulat3 = Math.round(result);
break;
}
case >:{
double bulat1= Math.round(opn1);
int x = (int)bulat1;
double bulat2= Math.round(opn2);
int y = (int)bulat2;
result = x >> y;
double bulat3 = Math.round(result);
break;
}
case #:{
double bulat1= Math.round(opn1);
int x = (int)bulat1;
double bulat2= Math.round(opn2);
int y = (int)bulat2;
result = x ^ y;
double bulat3 = Math.round(result);
break;
}
case &:{
double bulat1= Math.round(opn1);
int x = (int)bulat1;
double bulat2= Math.round(opn2);
int y = (int)bulat2;
result = x & y;
double bulat3 = Math.round(result);
break;
}
case |:{
double bulat1= Math.round(opn1);
int x = (int)bulat1;
double bulat2= Math.round(opn2);
int y = (int)bulat2;
result = x | y;
double bulat3 = Math.round(result);
break;
}
}
Double opn = new Double(result);
stackOfOperand.push(opn);
}
}

skala = ((Double)stackOfOperand.pop()).doubleValue();
return skala;
}
class PrioritasException extends Exception {
/**
*
*/
private static final long serialVersionUID = 1L;
private String message;
public PrioritasException(String _message) {
super(_message);
message = _message;
}
public String getMessage() {
return message;
}
public String toString() {
return PrioritasException: + getMessage();
}
public void printStackTrace() {
System.out.println(this);
super.fillInStackTrace();
}
}
}
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::
//membuat kelas konversi bilangan
public class Konversi_Bilangan {
public double dec ;
private String bin ;
private String oct ;
private String hex ;
public Konversi_Bilangan (){
dec = 0;
bin = ;
oct = ;
hex = ;
}

public Konversi_Bilangan (double a){


dec = a;
bin = decto(2);
oct = decto (8);
hex = decto(16);
}
public void set (double a){
dec = a;
bin = decto(2);
oct = decto (8);
hex = decto(16);
}
public void setbin (String a){
bin = a;
dec = todec(2,a);
oct = decto(8);
hex = decto(16);
}
public void setoct (String a){
oct = a;
dec = todec(8,a);
hex = decto(16);
bin = decto(2);
}
public void sethex (String a){
hex = a;
dec = todec(16,a);
oct = decto(8);
bin = decto(2);
}
public double get (){
return dec;
}
public String getBin (){
return bin;
}
public String getOct (){
return oct;
}
public String getHex (){
return hex;
}

private String decto (int base){


int tempi = (int)(dec);
String temp;
StringBuffer temp2 = new StringBuffer();
while (tempi >= base){
String z;
if (base <=9){
z = +tempi%base;
}
else {
if (tempi%base==10)
z = A;
else if (tempi%base==11)
z = B;
else if (tempi%base==12)
z = C;
else if (tempi%base==13)
z = D;
else if (tempi%base==14)
z = E;
else if (tempi%base==15)
z = F;
else
z = +tempi%base;
}
temp2.insert(0,z);
tempi = tempi/base;
}
String z;
if (base <=9){
z = +tempi;
}
else {
if (tempi==10)
z = A;
else if (tempi==11)
z = B;
else if (tempi==12)
z = C;
else if (tempi==13)
z = D;
else if (tempi==14)
z = E;
else if (tempi==15)
z = F;
else
z = +tempi;
}
temp2.insert(0,z);
temp = new String (temp2);

return temp;
}
public static double todec (int base, String input){
double a = 0;
for (int x =0; x<input.length(); x++){
String z;
if (base<10)
z = +input.charAt(x);
else
if (input.charAt(x)==A)
z = 10;
else if (input.charAt(x)==B)
z = 11;
else if (input.charAt(x)==C)
z = 12;
else if (input.charAt(x)==D)
z = 13;
else if (input.charAt(x)==E)
z = 14;
else if (input.charAt(x)==F)
z = 15;
else
z = +input.charAt(x);
a = a + Double.parseDouble(z) * Math.pow(base, input.length()-x-1);
}
return a;
}
}
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::
//membuat kelas kalkulator
public class Calculator extends javax.swing.JFrame {
String angka=;
Double total,angka1,konvert,tampung;
int pilih,b1,b2,kurung;
String Memory=;
double Mem;
char cek;
boolean TKpress,btotal;
/** Creates new form Calculator */
public Calculator() {
super(Kalkulator Scientific);
initComponents();
angka=;
}

Prioritas priority = new Prioritas();


String infixExp = , postfixExp = ;
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings(unchecked)
// <editor-fold defaultstate=collapsed desc=Generated Code>
private void initComponents() {
buttonGroup1 = new javax.swing.ButtonGroup();
buttonGroup2 = new javax.swing.ButtonGroup();
tampil = new javax.swing.JTextField();
jPanel2 = new javax.swing.JPanel();
cmddeg = new javax.swing.JRadioButton();
cmdrad = new javax.swing.JRadioButton();
jPanel1 = new javax.swing.JPanel();
cmdhex = new javax.swing.JRadioButton();
cmddec = new javax.swing.JRadioButton();
cmdoct = new javax.swing.JRadioButton();
cmdbin = new javax.swing.JRadioButton();
jPanel3 = new javax.swing.JPanel();
cmdinv = new javax.swing.JCheckBox();
cmdhyp = new javax.swing.JCheckBox();
Cmdbackspace = new javax.swing.JButton();
cmdCE = new javax.swing.JButton();
cmdclear = new javax.swing.JButton();
cmd7 = new javax.swing.JButton();
cmd8 = new javax.swing.JButton();
cmd9 = new javax.swing.JButton();
cmdbagi = new javax.swing.JButton();
cmdmod = new javax.swing.JButton();
cmdand = new javax.swing.JButton();
cmd4 = new javax.swing.JButton();
cmd5 = new javax.swing.JButton();
cmd6 = new javax.swing.JButton();
cmdkali = new javax.swing.JButton();
cmdor = new javax.swing.JButton();
cmdxor = new javax.swing.JButton();
cmd1 = new javax.swing.JButton();
cmd2 = new javax.swing.JButton();
cmd3 = new javax.swing.JButton();
cmdkurang = new javax.swing.JButton();
cmdlsh = new javax.swing.JButton();
cmdnot = new javax.swing.JButton();
cmd0 = new javax.swing.JButton();
cmdplus_minus = new javax.swing.JButton();
cmdcomma = new javax.swing.JButton();

cmdtambah = new javax.swing.JButton();


cmdhasil = new javax.swing.JButton();
cmdF = new javax.swing.JButton();
cmdA = new javax.swing.JButton();
cmdB = new javax.swing.JButton();
cmdC = new javax.swing.JButton();
cmdD = new javax.swing.JButton();
cmdE = new javax.swing.JButton();
cmdint = new javax.swing.JButton();
cmdmc = new javax.swing.JButton();
cmdmr = new javax.swing.JButton();
cmdms = new javax.swing.JButton();
cmdphi = new javax.swing.JButton();
cmdlen = new javax.swing.JButton();
cmdlog = new javax.swing.JButton();
cmdfaktorial = new javax.swing.JButton();
cmdper = new javax.swing.JButton();
cmdexp = new javax.swing.JButton();
cmdpow_y = new javax.swing.JButton();
cmdpow3 = new javax.swing.JButton();
cmdpow2 = new javax.swing.JButton();
cmdsin = new javax.swing.JButton();
cmdcos = new javax.swing.JButton();
cmdtan = new javax.swing.JButton();
tampil_M = new javax.swing.JTextField();
jTextField1 = new javax.swing.JTextField();
cmdmplus = new javax.swing.JButton();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
MenuKeluar = new javax.swing.JCheckBoxMenuItem();
jMenu2 = new javax.swing.JMenu();
jCheckBoxMenuItem1 = new javax.swing.JCheckBoxMenuItem();
jCheckBoxMenuItem2 = new javax.swing.JCheckBoxMenuItem();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setBackground(new java.awt.Color(255, 51, 51));
setResizable(false);
tampil.setEditable(false);
tampil.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
jPanel2.setBorder(new
javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
jPanel2.setAutoscrolls(true);
jPanel2.setEnabled(false);
buttonGroup2.add(cmddeg);
cmddeg.setSelected(true);
cmddeg.setText(Degrees);
cmddeg.setMargin(new java.awt.Insets(1, 1, 1, 1));

cmddeg.setRequestFocusEnabled(false);
cmddeg.setRolloverEnabled(false);
cmddeg.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmddegActionPerformed(evt);
}
});
buttonGroup2.add(cmdrad);
cmdrad.setText(Radians);
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(35, 35, 35)
.addComponent(cmddeg, javax.swing.GroupLayout.PREFERRED_SIZE, 78,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(29, 29, 29)
.addComponent(cmdrad)
.addContainerGap(33, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASEL
INE)
.addComponent(cmddeg)
.addComponent(cmdrad))
);
jPanel1.setBorder(new
javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
buttonGroup1.add(cmdhex);
cmdhex.setText(Hex);
cmdhex.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdhexActionPerformed(evt);
}
});
buttonGroup1.add(cmddec);
cmddec.setSelected(true);
cmddec.setText(Dec);
cmddec.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmddecActionPerformed(evt);
}
});

buttonGroup1.add(cmdoct);
cmdoct.setText(Oct);
cmdoct.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdoctActionPerformed(evt);
}
});
buttonGroup1.add(cmdbin);
cmdbin.setText(Bin);
cmdbin.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdbinActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(cmdhex, javax.swing.GroupLayout.PREFERRED_SIZE, 47,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cmddec)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cmdoct)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(cmdbin)
.addGap(43, 43, 43))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASEL
INE)
.addComponent(cmdhex)
.addComponent(cmddec)
.addComponent(cmdbin)
.addComponent(cmdoct))
);
jPanel3.setBorder(new
javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
cmdinv.setText(Inv);
cmdhyp.setText(Hyp);

javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);


jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addComponent(cmdinv)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(cmdhyp)
.addContainerGap())
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASEL
INE)
.addComponent(cmdinv)
.addComponent(cmdhyp))
);
Cmdbackspace.setFont(new java.awt.Font(Tahoma, 0, 10));
Cmdbackspace.setForeground(new java.awt.Color(255, 0, 0));
Cmdbackspace.setText(Backspace);
Cmdbackspace.setMargin(new java.awt.Insets(2, 2, 2, 2));
Cmdbackspace.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdbackspaceActionPerformed(evt);
}
});
cmdCE.setForeground(new java.awt.Color(255, 0, 0));
cmdCE.setText(CE);
cmdCE.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdCE.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdCEActionPerformed(evt);
}
});
cmdclear.setForeground(new java.awt.Color(255, 0, 0));
cmdclear.setText(C);
cmdclear.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdclear.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdclearActionPerformed(evt);
}
});
cmd7.setForeground(new java.awt.Color(0, 0, 255));
cmd7.setText(7);

cmd7.setBorder(null);
cmd7.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmd7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmd7ActionPerformed(evt);
}
});
cmd8.setForeground(new java.awt.Color(0, 0, 255));
cmd8.setText(8);
cmd8.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmd8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmd8ActionPerformed(evt);
}
});
cmd9.setForeground(new java.awt.Color(0, 0, 255));
cmd9.setText(9);
cmd9.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmd9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmd9ActionPerformed(evt);
}
});
cmdbagi.setForeground(new java.awt.Color(255, 0, 0));
cmdbagi.setText(/);
cmdbagi.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdbagi.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdbagiActionPerformed(evt);
}
});
cmdmod.setForeground(new java.awt.Color(255, 0, 0));
cmdmod.setText(Mod);
cmdmod.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdmod.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdmodActionPerformed(evt);
}
});
cmdand.setForeground(new java.awt.Color(255, 0, 0));
cmdand.setText(And);
cmdand.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdand.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdandActionPerformed(evt);

}
});
cmd4.setForeground(new java.awt.Color(0, 0, 255));
cmd4.setText(4);
cmd4.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmd4.setRequestFocusEnabled(false);
cmd4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmd4ActionPerformed(evt);
}
});
cmd5.setForeground(new java.awt.Color(0, 0, 255));
cmd5.setText(5);
cmd5.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmd5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmd5ActionPerformed(evt);
}
});
cmd6.setForeground(new java.awt.Color(0, 0, 255));
cmd6.setText(6);
cmd6.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmd6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmd6ActionPerformed(evt);
}
});
cmdkali.setForeground(new java.awt.Color(255, 0, 0));
cmdkali.setText(x);
cmdkali.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdkali.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdkaliActionPerformed(evt);
}
});
cmdor.setForeground(new java.awt.Color(255, 0, 0));
cmdor.setText(Or);
cmdor.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdor.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdorActionPerformed(evt);
}
});

cmdxor.setForeground(new java.awt.Color(255, 0, 0));


cmdxor.setText(Xor);
cmdxor.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdxor.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdxorActionPerformed(evt);
}
});
cmd1.setForeground(new java.awt.Color(0, 0, 255));
cmd1.setText(1);
cmd1.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmd1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmd1ActionPerformed(evt);
}
});
cmd2.setForeground(new java.awt.Color(0, 0, 255));
cmd2.setText(2);
cmd2.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmd2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmd2ActionPerformed(evt);
}
});
cmd3.setForeground(new java.awt.Color(0, 0, 255));
cmd3.setText(3);
cmd3.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmd3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmd3ActionPerformed(evt);
}
});
cmdkurang.setForeground(new java.awt.Color(255, 0, 0));
cmdkurang.setText(-);
cmdkurang.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdkurang.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdkurangActionPerformed(evt);
}
});
cmdlsh.setForeground(new java.awt.Color(255, 0, 0));
cmdlsh.setText(Lsh);
cmdlsh.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdlsh.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {

cmdlshActionPerformed(evt);
}
});
cmdnot.setForeground(new java.awt.Color(255, 0, 0));
cmdnot.setText(Not);
cmdnot.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdnot.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdnotActionPerformed(evt);
}
});
cmd0.setForeground(new java.awt.Color(0, 0, 255));
cmd0.setText(0);
cmd0.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmd0.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmd0ActionPerformed(evt);
}
});
cmdplus_minus.setForeground(new java.awt.Color(0, 0, 255));
cmdplus_minus.setText(+/-);
cmdplus_minus.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdplus_minus.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdplus_minusActionPerformed(evt);
}
});
cmdcomma.setForeground(new java.awt.Color(0, 0, 255));
cmdcomma.setText(,);
cmdcomma.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdcomma.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdcommaActionPerformed(evt);
}
});
cmdtambah.setForeground(new java.awt.Color(255, 0, 0));
cmdtambah.setText(+);
cmdtambah.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdtambah.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdtambahActionPerformed(evt);
}
});

cmdhasil.setForeground(new java.awt.Color(255, 0, 0));


cmdhasil.setText(=);
cmdhasil.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdhasil.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdhasilActionPerformed(evt);
}
});
cmdF.setForeground(new java.awt.Color(0, 0, 255));
cmdF.setText(F);
cmdF.setEnabled(false);
cmdF.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdF.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdFActionPerformed(evt);
}
});
cmdA.setForeground(new java.awt.Color(0, 0, 255));
cmdA.setText(A);
cmdA.setEnabled(false);
cmdA.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdA.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdAActionPerformed(evt);
}
});
cmdB.setForeground(new java.awt.Color(0, 0, 255));
cmdB.setText(B);
cmdB.setEnabled(false);
cmdB.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdB.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdBActionPerformed(evt);
}
});
cmdC.setForeground(new java.awt.Color(0, 0, 255));
cmdC.setText(C);
cmdC.setEnabled(false);
cmdC.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdC.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdCActionPerformed(evt);
}
});

cmdD.setForeground(new java.awt.Color(0, 0, 255));


cmdD.setText(D);
cmdD.setEnabled(false);
cmdD.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdD.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdDActionPerformed(evt);
}
});
cmdE.setForeground(new java.awt.Color(0, 0, 255));
cmdE.setText(E);
cmdE.setEnabled(false);
cmdE.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdE.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdEActionPerformed(evt);
}
});
cmdint.setForeground(new java.awt.Color(255, 0, 0));
cmdint.setText(Int);
cmdint.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdint.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdintActionPerformed(evt);
}
});
cmdmc.setForeground(new java.awt.Color(255, 0, 0));
cmdmc.setText(MC);
cmdmc.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdmc.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdmcActionPerformed(evt);
}
});
cmdmr.setForeground(new java.awt.Color(255, 0, 0));
cmdmr.setText(MR);
cmdmr.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdmr.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdmrActionPerformed(evt);
}
});
cmdms.setForeground(new java.awt.Color(255, 0, 0));
cmdms.setText(MS);
cmdms.setMargin(new java.awt.Insets(2, 2, 2, 2));

cmdms.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
cmdmsMouseClicked(evt);
}
});
cmdms.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdmsActionPerformed(evt);
}
});
cmdphi.setForeground(new java.awt.Color(0, 0, 255));
cmdphi.setText(phi);
cmdphi.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdphi.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdphiActionPerformed(evt);
}
});
cmdlen.setForeground(new java.awt.Color(153, 0, 153));
cmdlen.setText(ln);
cmdlen.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdlen.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdlenActionPerformed(evt);
}
});
cmdlog.setForeground(new java.awt.Color(153, 0, 153));
cmdlog.setText(log);
cmdlog.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdlog.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdlogActionPerformed(evt);
}
});
cmdfaktorial.setForeground(new java.awt.Color(153, 0, 153));
cmdfaktorial.setText(n!);
cmdfaktorial.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdfaktorial.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdfaktorialActionPerformed(evt);
}
});
cmdper.setForeground(new java.awt.Color(153, 0, 153));
cmdper.setText(1/x);
cmdper.setMargin(new java.awt.Insets(2, 2, 2, 2));

cmdper.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdperActionPerformed(evt);
}
});
cmdexp.setForeground(new java.awt.Color(153, 0, 153));
cmdexp.setText(Exp);
cmdexp.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdexp.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdexpActionPerformed(evt);
}
});
cmdpow_y.setForeground(new java.awt.Color(153, 0, 153));
cmdpow_y.setText(x^y);
cmdpow_y.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdpow_y.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdpow_yActionPerformed(evt);
}
});
cmdpow3.setForeground(new java.awt.Color(153, 0, 153));
cmdpow3.setText(x^3);
cmdpow3.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdpow3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdpow3ActionPerformed(evt);
}
});
cmdpow2.setForeground(new java.awt.Color(153, 0, 153));
cmdpow2.setText(x^2);
cmdpow2.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdpow2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdpow2ActionPerformed(evt);
}
});
cmdsin.setForeground(new java.awt.Color(153, 0, 153));
cmdsin.setText(sin);
cmdsin.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdsin.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdsinActionPerformed(evt);
}
});

cmdcos.setForeground(new java.awt.Color(153, 0, 153));


cmdcos.setText(cos);
cmdcos.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdcos.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdcosActionPerformed(evt);
}
});
cmdtan.setForeground(new java.awt.Color(153, 0, 153));
cmdtan.setText(tan);
cmdtan.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdtan.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdtanActionPerformed(evt);
}
});
tampil_M.setEditable(false);
tampil_M.setHorizontalAlignment(javax.swing.JTextField.CENTER);
tampil_M.setMargin(new java.awt.Insets(1, 1, 1, 1));
tampil_M.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tampil_MActionPerformed(evt);
}
});
jTextField1.setEditable(false);
jTextField1.setHorizontalAlignment(javax.swing.JTextField.CENTER);
jTextField1.setText(Calculator Scientific D Series);
jTextField1.setBorder(null);
cmdmplus.setForeground(new java.awt.Color(255, 0, 0));
cmdmplus.setText(M+);
cmdmplus.setMargin(new java.awt.Insets(2, 2, 2, 2));
cmdmplus.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
cmdmplusMouseClicked(evt);
}
});
cmdmplus.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdmplusActionPerformed(evt);
}
});
jMenu1.setText(File);
MenuKeluar.setSelected(true);
MenuKeluar.setText(Keluar);

MenuKeluar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
MenuKeluarActionPerformed(evt);
}
});
jMenu1.add(MenuKeluar);
jMenuBar1.add(jMenu1);
jMenu2.setText(View);
jCheckBoxMenuItem1.setSelected(true);
jCheckBoxMenuItem1.setText(Scientific);
jCheckBoxMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBoxMenuItem1ActionPerformed(evt);
}
});
jMenu2.add(jCheckBoxMenuItem1);
jCheckBoxMenuItem2.setText(Standar);
jCheckBoxMenuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBoxMenuItem2ActionPerformed(evt);
}
});
jMenu2.add(jCheckBoxMenuItem2);
jMenuBar1.add(jMenu2);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(tampil, javax.swing.GroupLayout.DEFAULT_SIZE, 449,
Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(cmdtan, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(cmdpow2, javax.swing.GroupLayout.PREFERRED_SIZE, 35,


javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(cmdcos, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cmdpow3, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(cmdsin, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cmdpow_y, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(cmdexp, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cmdlen, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(cmdlog, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdfaktorial, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdper, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(cmdmc, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(cmdmr, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdms, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdphi, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdmplus, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(jTextField1))
.addGap(47, 47, 47)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(cmd7, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(cmd1, javax.swing.GroupLayout.PREFERRED_SIZE, 35,


javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmd4, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmd0, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdA, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(cmd5, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdB, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdplus_minus, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmd2, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(cmdC, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmd3, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmd6, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdcomma, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(cmdD, javax.swing.GroupLayout.DEFAULT_SIZE, 35,
Short.MAX_VALUE)
.addComponent(cmdtambah, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdkali, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(cmdkurang, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(cmdE, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cmdF, javax.swing.GroupLayout.PREFERRED_SIZE, 35,

javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(cmdhasil, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cmdint, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(cmdor, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cmdxor, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(cmdlsh, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cmdnot, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cmd8, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cmd9, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cmdbagi, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cmdmod, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cmdand, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(4, 4, 4))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING,
false)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(tampil_M, javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.PREFERRED_SIZE, 199,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel2, 0, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(54, 54, 54)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(70, 70, 70)
.addComponent(cmdCE, javax.swing.GroupLayout.PREFERRED_SIZE, 60,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cmdclear, javax.swing.GroupLayout.PREFERRED_SIZE, 60,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(Cmdbackspace, javax.swing.GroupLayout.PREFERRED_SIZE, 60,
javax.swing.GroupLayout.PREFERRED_SIZE))))))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(tampil, javax.swing.GroupLayout.PREFERRED_SIZE, 29,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cmdCE, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdclear, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(Cmdbackspace, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(tampil_M, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)

.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cmd8, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmd9, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdbagi, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdmod, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdand, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmd7, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(cmd4, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cmd6, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdkali, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmd5, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdor, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdxor, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cmd2, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmd3, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmd1, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(cmdlsh, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdkurang, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cmdplus_minus, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdcomma, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(cmdtambah, javax.swing.GroupLayout.PREFERRED_SIZE, 30,


javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdhasil, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmd0, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdint, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cmdB, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdC, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdD, javax.swing.GroupLayout.DEFAULT_SIZE, 30,
Short.MAX_VALUE)
.addComponent(cmdE, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdF, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdA, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(cmdnot, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cmdmr, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdexp, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdlen, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdmc, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cmdsin, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdpow_y, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdlog, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdms, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cmdcos, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdpow3, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(cmdfaktorial, javax.swing.GroupLayout.PREFERRED_SIZE, 30,


javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdmplus, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cmdtan, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdpow2, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdper, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdphi, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addGroup(layout.createSequentialGroup()
.addGap(116, 116, 116)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
pack();
}// </editor-fold>
private void cmd8ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
angka +=8;
tampil.setText(angka);
}
private void cmd5ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
angka +=5;
tampil.setText(angka);
}
private void cmd0ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
angka +=0;
tampil.setText(angka);
}
private void cmd1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
angka +=1;
tampil.setText(angka);
}
private void cmd2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:

angka +=2;
tampil.setText(angka);
}
private void cmd3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
angka +=3;
tampil.setText(angka);
}
private void cmd4ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
angka +=4;
tampil.setText(angka);
}
private void cmd6ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
angka +=6;
tampil.setText(angka);
}
private void cmd7ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
angka +=7;
tampil.setText(angka);
}
private void cmd9ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
angka +=9;
tampil.setText(angka);
}
private void cmdtambahActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(TKpress==true){
infixExp+= + ;
}
else{
angka1=Double.parseDouble(tampil.getText());
infixExp+=angka1+ + ;
}
angka = ;
}
private void cmdkurangActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(TKpress==true){
infixExp+= ;

}
else{
angka1=Double.parseDouble(tampil.getText());
infixExp+=angka1+ ;
}
angka = ;
}
private void cmdkaliActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(TKpress==true){
infixExp+= * ;
}
else{
angka1=Double.parseDouble(tampil.getText());
infixExp+=angka1+ * ;
}
angka = ;
}
private void cmdbagiActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(TKpress==true){
infixExp+= / ;
}
else{
angka1=Double.parseDouble(tampil.getText());
infixExp+=angka1+ / ;
}
angka = ;
}
private void cmdmodActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(TKpress==true){
infixExp+= % ;
}
else{
angka1=Double.parseDouble(tampil.getText());
infixExp+=angka1+ % ;
}
angka = ;
}
public double proses(double input,String operator,String cOP,double total)
{
double jum=0;
if(operator.equals(+)){
jum=total+input;

tampung=input;
}
else if(operator.equals(*)){
if(cOP.equals(+)){
jum=(tampung*input)+(total-tampung);
tampung=tampung*input;
}
else if(cOP.equals(-)){
jum=(total+tampung)-(tampung*input);
tampung=tampung*input;
}
else{
jum=total*input;
}
}
else if(operator.equals(/)){
if(cOP.equals(+)){
jum=(tampung/input)+(total-tampung);
tampung=tampung/input;
}
else if(cOP.equals(-)){
jum=(total+tampung)-(tampung/input);
tampung=tampung/input;
}
else{
jum=total/input;
}
}
else if(operator.equals(-)){
jum=total-input;
tampung=input;
}
System.out.println(tampung);
return jum;
}
private void cmdhasilActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if((kurung==0)&&(!tampil.getText().equals()))){
angka1=Double.parseDouble(tampil.getText());
infixExp+=angka1;
}
try{
postfixExp = priority.convertToPostfix(infixExp);
total=priority.evaluate(postfixExp);

}
catch(Exception e){
e.printStackTrace();
}
tampil.setText(+(total));
btotal=true;
infixExp=;
System.out.println(+infixExp);
TKpress=false;
angka=;
}
private void cmdCEActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
tampil.setText();
}
private void cmdclearActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
angka1 = 0.0;
total = 0.0;
angka = ;
tampil.setText();
}
private void cmdsinActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String sin = tampil.getText();
double derajat = Double.parseDouble(sin);
double pi = Math.PI;
//dalam bentuk degrees//
double hasil = Math.sin(derajat * pi/180);
tampil.setText(Double.toString(hasil));
if(derajat%180==0){
tampil.setText(0.0);
}
if(cmdhyp.isSelected()==true&&cmdinv.isSelected()==false){
hasil = Math.sinh(derajat);
tampil.setText(Double.toString(hasil));
cmdhyp.setSelected(false);
}
if(cmdinv.isSelected()==true&&cmdhyp.isSelected()==false){
hasil = Math.asin(derajat)*180/pi;
tampil.setText(Double.toString(hasil));
if(derajat==1){

tampil.setText(90);
}
cmdinv.setSelected(false);
}
if(cmdinv.isSelected()==true && cmdhyp.isSelected()==true){
double proseshasil =Math.pow(derajat, 2)+1.0;
double proseshasil2 = Math.sqrt(proseshasil);
hasil = Math.log(derajat+proseshasil2);
tampil.setText(Double.toString(hasil));
cmdhyp.setSelected(false);
cmdinv.setSelected(false);
}
//dalam bentuk radian//
if(cmdrad.isSelected()==true){
hasil = Math.sin(derajat);
tampil.setText(Double.toString(hasil));
}
if(cmdrad.isSelected()==true && cmdhyp.isSelected()==true &&
cmdinv.isSelected()==false){
hasil = Math.sinh(derajat);
tampil.setText(Double.toString(hasil));
cmdhyp.setSelected(false);
}
if(cmdrad.isSelected()==true && cmdinv.isSelected()==true &&
cmdhyp.isSelected()==false){
hasil = Math.asin(derajat);
tampil.setText(Double.toString(hasil));
cmdinv.setSelected(false);
}
if(cmdrad.isSelected()==true && cmdinv.isSelected()==true && cmdhyp.isSelected()==true)
{
double proseshasil =Math.pow(derajat, 2)+1.0;
double proseshasil2 = Math.sqrt(proseshasil);
hasil = Math.log(derajat+proseshasil2);
tampil.setText(Double.toString(hasil));
cmdinv.setSelected(false);
cmdhyp.setSelected(false);
}
}
private void CmdbackspaceActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
angka = angka.substring(0, angka.length()-1);
tampil.setText(angka);
}
private void cmdplus_minusActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(!angka.contains(-))

angka = -+angka;
else
angka = angka.substring(1, angka.length());
tampil.setText(angka);
}
private void cmdcosActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String cos = tampil.getText();
double derajat = Double.parseDouble(cos);
double pi = Math.PI;
//dalam bentuk degrees//
double hasil = Math.cos(derajat * pi/180);
tampil.setText(Double.toString(hasil));
if(derajat ==90 ){
tampil.setText(0);
}
if(derajat%270==0){
tampil.setText(0);
}
if(cmdhyp.isSelected()==true && cmdinv.isSelected()==false){
hasil = Math.cosh(derajat);
tampil.setText(Double.toString(hasil));
cmdhyp.setSelected(false);
}
if(cmdinv.isSelected()==true && cmdhyp.isSelected()==false){
hasil = Math.acos(derajat)*180/pi;
tampil.setText(Double.toString(hasil));
cmdinv.setSelected(false);
}
if(cmdinv.isSelected()==true && cmdhyp.isSelected()==true){
double proseshasil =Math.pow(derajat, 2)-1.0;
double proseshasil2 = Math.sqrt(proseshasil);
hasil = Math.log(derajat+proseshasil2);
tampil.setText(Double.toString(hasil));
cmdhyp.setSelected(false);
cmdinv.setSelected(false);
}
//dalam bentuk radian//
if(cmdrad.isSelected()==true){
hasil = Math.cos(derajat);
tampil.setText(Double.toString(hasil));
}
if(cmdrad.isSelected()==true && cmdhyp.isSelected()==true &&
cmdinv.isSelected()==false){
hasil = Math.cosh(derajat);
tampil.setText(Double.toString(hasil));
cmdhyp.setSelected(false);
}

if(cmdrad.isSelected()==true && cmdinv.isSelected()==true &&


cmdhyp.isSelected()==false){
hasil = Math.acos(derajat);
tampil.setText(Double.toString(hasil));
cmdinv.setSelected(false);
}
if(cmdrad.isSelected()==true && cmdinv.isSelected()==true && cmdhyp.isSelected()==true)
{
double proseshasil =Math.pow(derajat, 2)-1.0;
double proseshasil2 = Math.sqrt(proseshasil);
hasil = Math.log(derajat+proseshasil2);
tampil.setText(Double.toString(hasil));
cmdinv.setSelected(false);
cmdhyp.setSelected(false);
}
}
private void cmdcommaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
angka +=.;
Double comma= Double.parseDouble(angka);
}
private void cmdtanActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String tan = tampil.getText();
double derajat = Double.parseDouble(tan);
double pi = Math.PI;
//dalam bentuk degrees//
double hasil = Math.tan(derajat * pi/180);
tampil.setText(Double.toString(hasil));
if(derajat%90==0 || derajat%270==0){
tampil.setText(Math ERROR);
}
if(derajat%180==0|| derajat%360==0){
tampil.setText(0);
}
if(derajat ==45 || derajat % 225==0){
tampil.setText(1.0);
}
if(derajat%135==0||derajat%315==0){
tampil.setText(-1.0);
}
if(cmdhyp.isSelected()==true && cmdinv.isSelected()==false){
hasil = Math.tanh(derajat);
tampil.setText(Double.toString(hasil));
cmdhyp.setSelected(false);
}
if(cmdinv.isSelected()==true && cmdhyp.isSelected()==false){

hasil = Math.atan(derajat)*180/pi;
tampil.setText(Double.toString(hasil));
cmdinv.setSelected(false);
}
//dalam bentuk radian//
if(cmdrad.isSelected()==true){
hasil = Math.tan(derajat);
tampil.setText(Double.toString(hasil));
}
if(cmdrad.isSelected()==true && cmdhyp.isSelected()==true &&
cmdinv.isSelected()==false){
hasil = Math.tanh(derajat);
tampil.setText(Double.toString(hasil));
cmdhyp.setSelected(false);
}
if(cmdrad.isSelected()==true && cmdinv.isSelected()==true &&
cmdhyp.isSelected()==false){
hasil = Math.atan(derajat);
tampil.setText(Double.toString(hasil));
cmdinv.setSelected(false);
}
}
private void cmdperActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String per = tampil.getText();
double perperan = Double.parseDouble(per);
double hasil = 1/perperan;
tampil.setText(Double.toString(hasil));
}
private void cmdpow2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String pow_2 = tampil.getText();
double pw = Double.parseDouble(pow_2);
double hasil = Math.pow(pw,2);
tampil.setText(Double.toString(hasil));
if(cmdinv.isSelected()==true){
hasil = Math.pow(pw, 0.5);
tampil.setText(Double.toString(hasil));
cmdinv.setSelected(false);
}
}
private void cmdpow3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String pow_3 = tampil.getText();
double pw = Double.parseDouble(pow_3);

double hasil = Math.pow(pw,3);


tampil.setText(Double.toString(hasil));
if(cmdinv.isSelected()==true){
hasil = Math.pow(pw,1/3.0);
tampil.setText(Double.toString(hasil));
cmdinv.setSelected(false);
}
}
private void cmdlogActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String logaritma = tampil.getText();
double a = Double.parseDouble(logaritma);
double hasil = Math.log10(a);
tampil.setText(Double.toString(hasil));
if(a<0){
tampil.setText(Math ERROR);
}
if(cmdinv.isSelected()==true){
hasil = Math.pow(10.0, a);
double pembulatan = Math.round(hasil);
tampil.setText(Double.toString(pembulatan));
cmdinv.setSelected(false);
}
}
private void cmdphiActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
double hasil = Math.PI;
tampil.setText(Double.toString(hasil));
}
private void cmdlenActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String ln = tampil.getText();
double b = Double.parseDouble(ln);
double hasil = Math.log(b);
tampil.setText(Double.toString(hasil));
if(b<0){
tampil.setText(Math ERROR);
}
if(cmdinv.isSelected()==true){
hasil = Math.pow((Math.E),b);
double pembulatan = Math.round(hasil);
tampil.setText(Double.toString(pembulatan));
cmdinv.setSelected(false);
}

}
private void cmdpow_yActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(TKpress==true){
infixExp+= ^ ;
if(cmdinv.isSelected()==true){
infixExp+= ^ 1 / ;
}
}
else{
angka1=Double.parseDouble(tampil.getText());
infixExp+=angka1+ ^ ;
if(cmdinv.isSelected()==true){
angka1=Double.parseDouble(tampil.getText());
infixExp+=angka1+ ^ 1 / ;
}
}
angka = ;
}
private void cmdexpActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
angka1 = Double.parseDouble(angka);
tampil.setText(angka);
angka = ;
pilih = 7;
}
private void cmdAActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
angka+=A;
tampil.setText(angka);
}
private void cmdBActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
angka+=B;
tampil.setText(angka);
}
private void cmdCActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
angka+=C;
tampil.setText(angka);
}

private void cmdDActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
angka+=D;
tampil.setText(angka);
}
private void cmdEActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
angka+=E;
tampil.setText(angka);
}
private void cmdFActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
angka+=F;
tampil.setText(angka);
}
private void cmdhexActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
cmdA.setEnabled(true);
cmdB.setEnabled(true);
cmdC.setEnabled(true);
cmdD.setEnabled(true);
cmdE.setEnabled(true);
cmdF.setEnabled(true);
cmdphi.setEnabled(false);
cmdsin.setEnabled(false);
cmdcos.setEnabled(false);
cmdtan.setEnabled(false);
cmdexp.setEnabled(false);
cmd0.setEnabled(true);
cmd1.setEnabled(true);
cmd2.setEnabled(true);
cmd3.setEnabled(true);
cmd4.setEnabled(true);
cmd5.setEnabled(true);
cmd6.setEnabled(true);
cmd7.setEnabled(true);
cmd8.setEnabled(true);
cmd9.setEnabled(true);
Konversi_Bilangan bil = new Konversi_Bilangan();
String hexa = tampil.getText();
double konverti = Double.parseDouble(hexa);
bil.set(konverti);
tampil.setText(bil.getHex());
if(cek == o){
bil.setoct(hexa);

tampil.setText(bil.getHex());
}
else if (cek == b){
bil.setbin(hexa);
tampil.setText(bil.getHex());
}
else if (cek == d){
bil = new Konversi_Bilangan (konverti);
tampil.setText(+bil.getHex());
}
cek = h;
}
private void cmddecActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
cmdA.setEnabled(false);
cmdB.setEnabled(false);
cmdC.setEnabled(false);
cmdD.setEnabled(false);
cmdE.setEnabled(false);
cmdF.setEnabled(false);
cmdphi.setEnabled(true);
cmdsin.setEnabled(true);
cmdcos.setEnabled(true);
cmdtan.setEnabled(true);
cmdexp.setEnabled(true);
cmd0.setEnabled(true);
cmd1.setEnabled(true);
cmd2.setEnabled(true);
cmd3.setEnabled(true);
cmd4.setEnabled(true);
cmd5.setEnabled(true);
cmd6.setEnabled(true);
cmd7.setEnabled(true);
cmd8.setEnabled(true);
cmd9.setEnabled(true);
Konversi_Bilangan bil = new Konversi_Bilangan();
String desi = tampil.getText();
double konverti = Double.parseDouble(desi);
bil.set(konverti);
tampil.setText(+bil.get());
if(cek == h){
bil.sethex(desi);
tampil.setText(+bil.get());
}
else if (cek == o){
bil.setoct(desi);

tampil.setText(+bil.get());
}
else if (cek == b){
bil.setbin(desi);
tampil.setText(+bil.get());
}
cek =d;
}
private void cmdoctActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
cmdA.setEnabled(false);
cmdB.setEnabled(false);
cmdC.setEnabled(false);
cmdD.setEnabled(false);
cmdE.setEnabled(false);
cmdF.setEnabled(false);
cmdphi.setEnabled(false);
cmdsin.setEnabled(false);
cmdcos.setEnabled(false);
cmdtan.setEnabled(false);
cmdexp.setEnabled(false);
cmd0.setEnabled(true);
cmd1.setEnabled(true);
cmd2.setEnabled(true);
cmd3.setEnabled(true);
cmd4.setEnabled(true);
cmd5.setEnabled(true);
cmd6.setEnabled(true);
cmd7.setEnabled(true);
cmd8.setEnabled(false);
cmd9.setEnabled(false);
Konversi_Bilangan bil = new Konversi_Bilangan();
String octal = tampil.getText();
double konverti = Double.parseDouble(octal);
bil.set(konverti);
tampil.setText(bil.getOct());
if(cek == h){
bil.sethex(octal);
tampil.setText(bil.getOct());
}
else if (cek == b){
bil.setbin(octal);
tampil.setText(bil.getOct());
}
else if (cek == d){
bil = new Konversi_Bilangan (konverti);
tampil.setText(+bil.getOct());

}
cek =o;
}
private void cmdbinActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
cmdA.setEnabled(false);
cmdB.setEnabled(false);
cmdC.setEnabled(false);
cmdD.setEnabled(false);
cmdE.setEnabled(false);
cmdF.setEnabled(false);
cmdphi.setEnabled(false);
cmdsin.setEnabled(false);
cmdcos.setEnabled(false);
cmdtan.setEnabled(false);
cmdexp.setEnabled(false);
cmd0.setEnabled(true);
cmd1.setEnabled(true);
cmd2.setEnabled(false);
cmd3.setEnabled(false);
cmd4.setEnabled(false);
cmd5.setEnabled(false);
cmd6.setEnabled(false);
cmd7.setEnabled(false);
cmd8.setEnabled(false);
cmd9.setEnabled(false);
Konversi_Bilangan bil = new Konversi_Bilangan();
String biner = tampil.getText();
double konverti = Double.parseDouble(biner);
bil.set(konverti);
tampil.setText(bil.getBin());
if(cek == h){
bil.sethex(biner);
tampil.setText(bil.getBin());
}
else if (cek == o){
bil.setoct(biner);
tampil.setText(bil.getBin());
}
else if (cek == d){
bil = new Konversi_Bilangan (konverti);
tampil.setText(+bil.getBin());
}
cek =b;
}

private void cmdlshActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
b1 = Integer.parseInt(angka);
tampil.setText(angka);
angka = ;
pilih = 8;
}
private void cmdnotActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String not = tampil.getText();
int ubah = Integer.parseInt(not);
int hasil = ~ubah;
tampil.setText(Integer.toString(hasil));
}
private void cmdandActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(TKpress==true){
infixExp+= & ;
}
else{
double input1=Double.parseDouble(tampil.getText());
int bulat = (int)input1;
infixExp+=input1+ & ;
angka=;
}
}
private void cmdorActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(TKpress==true){
infixExp+= & ;
}
else{
double input1=Double.parseDouble(tampil.getText());
int bulat = (int)input1;
infixExp+=input1+ | ;
angka=;
}
}
private void cmdxorActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(TKpress==true){
infixExp+= & ;
}
else{

double input1=Double.parseDouble(tampil.getText());
int bulat = (int)input1;
infixExp+=input1+ ^ ;
angka=;
}
}
private void cmdintActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String compress_2int = tampil.getText();
double desimal = Double.parseDouble(compress_2int);
int hasil = ~(int)desimal;
tampil.setText(Integer.toString(hasil));
}
private void cmdmrActionPerformed(java.awt.event.ActionEvent evt) {
tampil.setText(Double.toString(Mem));
}
private void cmdmcActionPerformed(java.awt.event.ActionEvent evt) {
Mem = 0.0;
tampil_M.setText();
}
private void tampil_MActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void cmdmsMouseClicked(java.awt.event.MouseEvent evt) {
Mem = Double.parseDouble(angka);
tampil_M.setText(M);// TODO add your handling code here:
}
private void cmdfaktorialActionPerformed(java.awt.event.ActionEvent evt) {
double fak=1;
double x = Double.parseDouble(angka);
for(double i=x; i>=1; i){
fak *= i;
}
tampil.setText(Double.toString(fak));
// TODO add your handling code here:
}
private void cmddegActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}

private void cmdmsActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
}
private void jCheckBoxMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Calculator_Standar().setVisible(true);
}
});
this.setVisible(false);// TODO add your handling code here:
}
private void jCheckBoxMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Calculator_Standar().setVisible(true);
}
});
this.setVisible(false);
}
private void MenuKeluarActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(2);// TODO add your handling code here:
}
private void cmdmplusMouseClicked(java.awt.event.MouseEvent evt) {
double Mem1 = Double.parseDouble(angka);
Mem += Mem1;
tampil_M.setText(M);
tampil.setText(Double.toString(Mem1));
// TODO add your handling code here:
}
private void cmdmplusActionPerformed(java.awt.event.ActionEvent evt) {
/*double a = Double.parseDouble(Screen.getText());
hasil = Mem + a;
a=0.0;
Text1.setText(M);
Screen.setText();*/
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {

new Calculator().setVisible(true);
}
});
}
// Variables declaration do not modify
private javax.swing.JButton Cmdbackspace;
private javax.swing.JCheckBoxMenuItem MenuKeluar;
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.ButtonGroup buttonGroup2;
private javax.swing.JButton cmd0;
private javax.swing.JButton cmd1;
private javax.swing.JButton cmd2;
private javax.swing.JButton cmd3;
private javax.swing.JButton cmd4;
private javax.swing.JButton cmd5;
private javax.swing.JButton cmd6;
private javax.swing.JButton cmd7;
private javax.swing.JButton cmd8;
private javax.swing.JButton cmd9;
private javax.swing.JButton cmdA;
private javax.swing.JButton cmdB;
private javax.swing.JButton cmdC;
private javax.swing.JButton cmdCE;
private javax.swing.JButton cmdD;
private javax.swing.JButton cmdE;
private javax.swing.JButton cmdF;
private javax.swing.JButton cmdand;
private javax.swing.JButton cmdbagi;
private javax.swing.JRadioButton cmdbin;
private javax.swing.JButton cmdclear;
private javax.swing.JButton cmdcomma;
private javax.swing.JButton cmdcos;
private javax.swing.JRadioButton cmddec;
private javax.swing.JRadioButton cmddeg;
private javax.swing.JButton cmdexp;
private javax.swing.JButton cmdfaktorial;
private javax.swing.JButton cmdhasil;
private javax.swing.JRadioButton cmdhex;
private javax.swing.JCheckBox cmdhyp;
private javax.swing.JButton cmdint;
private javax.swing.JCheckBox cmdinv;
private javax.swing.JButton cmdkali;
private javax.swing.JButton cmdkurang;
private javax.swing.JButton cmdlen;
private javax.swing.JButton cmdlog;
private javax.swing.JButton cmdlsh;
private javax.swing.JButton cmdmc;
private javax.swing.JButton cmdmod;
private javax.swing.JButton cmdmplus;

private javax.swing.JButton cmdmr;


private javax.swing.JButton cmdms;
private javax.swing.JButton cmdnot;
private javax.swing.JRadioButton cmdoct;
private javax.swing.JButton cmdor;
private javax.swing.JButton cmdper;
private javax.swing.JButton cmdphi;
private javax.swing.JButton cmdplus_minus;
private javax.swing.JButton cmdpow2;
private javax.swing.JButton cmdpow3;
private javax.swing.JButton cmdpow_y;
private javax.swing.JRadioButton cmdrad;
private javax.swing.JButton cmdsin;
private javax.swing.JButton cmdtambah;
private javax.swing.JButton cmdtan;
private javax.swing.JButton cmdxor;
private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem1;
private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem2;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField tampil;
private javax.swing.JTextField tampil_M;
// End of variables declaration
}

You might also like