write a program on eclipse where you would build your own scientific calculator that can use algebraic notations
package lecture;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
public class scienticalci extends JFrame implements
ActionListener {
JTextField textfield;
double temporary, temporary1, r, tempa;
static double tm1, tm2;
int k = 1, x1 = 0, y1 = 0, z1 = 0;
char choice;
JButton button1, button2, button3, button4, button5,
button6, button7, button8, button9, zero, clr, pow2, pow3,
exp,
fac, plus,
minus, division, logrithmic, rec, multiplication, eq, addSub, dot,
mr, mc, mp,
mm, sqrt, sin,
cos, tan;
Container container;
JPanel tpane, bpane;
scienticalci() {
container = getContentPane();
container.setLayout(new
BorderLayout());
JPanel textpanel = new
JPanel();
textfield = new
JTextField(25);
textfield.setHorizontalAlignment(SwingConstants.RIGHT);
textfield.addKeyListener(new
KeyAdapter() {
public void
keyTyped(KeyEvent keyevent) {
char c = keyevent.getKeyChar();
if (c >= '0' && c <= '9') {
} else {
keyevent.consume();
}
}
});
textpanel.add(textfield);
bpane = new JPanel();
bpane.setLayout(new GridLayout(8,
4, 2, 2));
boolean t = true;
mr = new JButton("MR");
bpane.add(mr);
mr.addActionListener(this);
mc = new JButton("MC");
bpane.add(mc);
mc.addActionListener(this);
mp = new JButton("M+");
bpane.add(mp);
mp.addActionListener(this);
mm = new JButton("M-");
bpane.add(mm);
mm.addActionListener(this);
button1 = new
JButton("1");
bpane.add(button1);
button1.addActionListener(this);
button2 = new JButton("2");
bpane.add(button2);
button2.addActionListener(this);
button3 = new JButton("3");
bpane.add(button3);
button3.addActionListener(this);
button4 = new
JButton("4");
bpane.add(button4);
button4.addActionListener(this);
button5 = new JButton("5");
bpane.add(button5);
button5.addActionListener(this);
button6 = new JButton("6");
bpane.add(button6);
button6.addActionListener(this);
button7 = new
JButton("7");
bpane.add(button7);
button7.addActionListener(this);
button8 = new JButton("8");
bpane.add(button8);
button8.addActionListener(this);
button9 = new JButton("9");
bpane.add(button9);
button9.addActionListener(this);
zero = new JButton("0");
bpane.add(zero);
zero.addActionListener(this);
plus = new JButton("+");
bpane.add(plus);
plus.addActionListener(this);
minus = new JButton("-");
bpane.add(minus);
minus.addActionListener(this);
multiplication = new
JButton("*");
bpane.add(multiplication);
multiplication.addActionListener(this);
division = new
JButton("/");
division.addActionListener(this);
bpane.add(division);
addSub = new
JButton("+/-");
bpane.add(addSub);
addSub.addActionListener(this);
dot = new JButton(".");
bpane.add(dot);
dot.addActionListener(this);
eq = new JButton("=");
bpane.add(eq);
eq.addActionListener(this);
rec = new JButton("1/x1");
bpane.add(rec);
rec.addActionListener(this);
sqrt = new JButton("Sqrt");
bpane.add(sqrt);
sqrt.addActionListener(this);
logrithmic = new
JButton("logrithmic");
bpane.add(logrithmic);
logrithmic.addActionListener(this);
sin = new JButton("SIN");
bpane.add(sin);
sin.addActionListener(this);
cos = new JButton("COS");
bpane.add(cos);
cos.addActionListener(this);
tan = new JButton("TAN");
bpane.add(tan);
tan.addActionListener(this);
pow2 = new JButton("x1^2");
bpane.add(pow2);
pow2.addActionListener(this);
pow3 = new JButton("x1^3");
bpane.add(pow3);
pow3.addActionListener(this);
exp = new JButton("Exp");
exp.addActionListener(this);
bpane.add(exp);
fac = new JButton("n!");
fac.addActionListener(this);
bpane.add(fac);
clr = new JButton("AC");
bpane.add(clr);
clr.addActionListener(this);
container.add("Center",
bpane);
container.add("North",
textpanel);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e) {
String temps =
e.getActionCommand();
if (temps.equals("1")) {
if (z1 == 0)
{
textfield.setText(textfield.getText() +
"1");
} else {
textfield.setText("");
textfield.setText(textfield.getText() +
"1");
z1 = 0;
}
}
if (temps.equals("2")) {
if (z1 == 0)
{
textfield.setText(textfield.getText() +
"2");
} else {
textfield.setText("");
textfield.setText(textfield.getText() +
"2");
z1 = 0;
}
}
if (temps.equals("3")) {
if (z1 == 0)
{
textfield.setText(textfield.getText() +
"3");
} else {
textfield.setText("");
textfield.setText(textfield.getText() +
"3");
z1 = 0;
}
}
if (temps.equals("4")) {
if (z1 == 0)
{
textfield.setText(textfield.getText() +
"4");
} else {
textfield.setText("");
textfield.setText(textfield.getText() +
"4");
z1 = 0;
}
}
if (temps.equals("5")) {
if (z1 == 0)
{
textfield.setText(textfield.getText() +
"5");
} else {
textfield.setText("");
textfield.setText(textfield.getText() +
"5");
z1 = 0;
}
}
if (temps.equals("6")) {
if (z1 == 0)
{
textfield.setText(textfield.getText() +
"6");
} else {
textfield.setText("");
textfield.setText(textfield.getText() +
"6");
z1 = 0;
}
}
if (temps.equals("7")) {
if (z1 == 0)
{
textfield.setText(textfield.getText() +
"7");
} else {
textfield.setText("");
textfield.setText(textfield.getText() +
"7");
z1 = 0;
}
}
if (temps.equals("8")) {
if (z1 == 0)
{
textfield.setText(textfield.getText() +
"8");
} else {
textfield.setText("");
textfield.setText(textfield.getText() +
"8");
z1 = 0;
}
}
if (temps.equals("9")) {
if (z1 == 0)
{
textfield.setText(textfield.getText() +
"9");
} else {
textfield.setText("");
textfield.setText(textfield.getText() +
"9");
z1 = 0;
}
}
if (temps.equals("0")) {
if (z1 == 0)
{
textfield.setText(textfield.getText() +
"0");
} else {
textfield.setText("");
textfield.setText(textfield.getText() +
"0");
z1 = 0;
}
}
if (temps.equals("AC")) {
textfield.setText("");
x1 = 0;
y1 = 0;
z1 = 0;
}
if (temps.equals("logrithmic"))
{
if
(textfield.getText().equals("")) {
textfield.setText("");
} else {
tempa =
Math.log(Double.parseDouble(textfield.getText()));
textfield.setText("");
textfield.setText(textfield.getText() +
tempa);
}
}
if (temps.equals("1/x1")) {
if
(textfield.getText().equals("")) {
textfield.setText("");
} else {
tempa = 1 /
Double.parseDouble(textfield.getText());
textfield.setText("");
textfield.setText(textfield.getText() +
tempa);
}
}
if (temps.equals("Exp")) {
if
(textfield.getText().equals("")) {
textfield.setText("");
} else {
tempa =
Math.exp(Double.parseDouble(textfield.getText()));
textfield.setText("");
textfield.setText(textfield.getText() +
tempa);
}
}
if (temps.equals("x1^2")) {
if
(textfield.getText().equals("")) {
textfield.setText("");
} else {
tempa =
Math.pow(Double.parseDouble(textfield.getText()), 2);
textfield.setText("");
textfield.setText(textfield.getText() +
tempa);
}
}
if (temps.equals("x1^3")) {
if
(textfield.getText().equals("")) {
textfield.setText("");
} else {
tempa =
Math.pow(Double.parseDouble(textfield.getText()), 3);
textfield.setText("");
textfield.setText(textfield.getText() +
tempa);
}
}
if (temps.equals("+/-")) {
if (x1 == 0)
{
textfield.setText("-" +
textfield.getText());
x1 = 1;
} else {
textfield.setText(textfield.getText());
}
}
if (temps.equals(".")) {
if (y1 == 0)
{
textfield.setText(textfield.getText() +
".");
y1 = 1;
} else {
textfield.setText(textfield.getText());
}
}
if (temps.equals("+")) {
if
(textfield.getText().equals("")) {
textfield.setText("");
temporary = 0;
choice = '+';
} else {
temporary =
Double.parseDouble(textfield.getText());
textfield.setText("");
choice = '+';
y1 = 0;
x1 = 0;
}
textfield.requestFocus();
}
if (temps.equals("-")) {
if
(textfield.getText().equals("")) {
textfield.setText("");
temporary = 0;
choice = '-';
} else {
x1 = 0;
y1 = 0;
temporary =
Double.parseDouble(textfield.getText());
textfield.setText("");
choice = '-';
}
textfield.requestFocus();
}
if (temps.equals("/")) {
if
(textfield.getText().equals("")) {
textfield.setText("");
temporary = 1;
choice = '/';
} else {
x1 = 0;
y1 = 0;
temporary =
Double.parseDouble(textfield.getText());
choice = '/';
textfield.setText("");
}
textfield.requestFocus();
}
if (temps.equals("*")) {
if
(textfield.getText().equals("")) {
textfield.setText("");
temporary = 1;
choice = '*';
} else {
x1 = 0;
y1 = 0;
temporary =
Double.parseDouble(textfield.getText());
choice = '*';
textfield.setText("");
}
textfield.requestFocus();
}
if (temps.equals("MC")) {
tm1 = 0;
textfield.setText("");
}
if (temps.equals("MR")) {
textfield.setText("");
textfield.setText(textfield.getText() + tm1);
}
if (temps.equals("M+")) {
if (k == 1)
{
tm1 =
Double.parseDouble(textfield.getText());
k++;
} else {
tm1 +=
Double.parseDouble(textfield.getText());
textfield.setText("" + tm1);
}
}
if (temps.equals("M-")) {
if (k == 1)
{
tm1 =
Double.parseDouble(textfield.getText());
k++;
} else {
tm1 -=
Double.parseDouble(textfield.getText());
textfield.setText("" + tm1);
}
}
if (temps.equals("Sqrt")) {
if
(textfield.getText().equals("")) {
textfield.setText("");
} else {
tempa =
Math.sqrt(Double.parseDouble(textfield.getText()));
textfield.setText("");
textfield.setText(textfield.getText() +
tempa);
}
}
if (temps.equals("SIN")) {
if
(textfield.getText().equals("")) {
textfield.setText("");
} else {
tempa =
Math.sin(Double.parseDouble(textfield.getText()));
textfield.setText("");
textfield.setText(textfield.getText() +
tempa);
}
}
if (temps.equals("COS")) {
if
(textfield.getText().equals("")) {
textfield.setText("");
} else {
tempa =
Math.cos(Double.parseDouble(textfield.getText()));
textfield.setText("");
textfield.setText(textfield.getText() +
tempa);
}
}
if (temps.equals("TAN")) {
if
(textfield.getText().equals("")) {
textfield.setText("");
} else {
tempa =
Math.tan(Double.parseDouble(textfield.getText()));
textfield.setText("");
textfield.setText(textfield.getText() +
tempa);
}
}
if (temps.equals("=")) {
if
(textfield.getText().equals("")) {
textfield.setText("");
} else {
temporary1 =
Double.parseDouble(textfield.getText());
switch (choice) {
case '+':
r = temporary +
temporary1;
break;
case '-':
r = temporary -
temporary1;
break;
case '/':
r = temporary /
temporary1;
break;
case '*':
r = temporary *
temporary1;
break;
}
textfield.setText("");
textfield.setText(textfield.getText() +
r);
z1 = 1;
}
}
if (temps.equals("n!")) {
if
(textfield.getText().equals("")) {
textfield.setText("");
} else {
tempa =
fact(Double.parseDouble(textfield.getText()));
textfield.setText("");
textfield.setText(textfield.getText() +
tempa);
}
}
textfield.requestFocus();
}
double fact(double x1) {
int er = 0;
if (x1 < 0) {
er = 20;
return 0;
}
double p, temps = 1;
for (p = 2; p <= x1; p +=
1.0)
temps *=
p;
return temps;
}
public static void main(String args[]) {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (Exception e) {
}
SwingCalculator f = new
SwingCalculator();
f.setTitle("ScientificCalculator");
f.pack();
f.setVisible(true);
}
}
DON'T FORGET TO LIKE
THANKS BY HEART.
write a program on eclipse where you would build your own scientific calculator that can use...
Be sure that you can use your calculator to enter scientific notation and perform operations with It. Use your calculator to perform these operations and write the answer in the space provided: Problem Answer 8.4x102 (3.5 x 10-22.4x105) 8.45x103 7.8 x 103 + 6.5 x 102 2.92x1014 9.37 x 109 +3.2 x 10-5 1.36x10-3 3.44x1018 x 238 6.02 x 1023 2.26x10-12 0.00392 x 7.5 x 10-4 1.3 x 106
Write a 1-2-page report on your experience with learning Eclipse. What could be provided that would have made the experience easier? Use the “Hello World” program in Chapter 1 as a reference and write a Perl program with file name of greetings.pl. Your program will display one or two lines to introduce yourself. After you finish the greetings.pl program, run it, and make a print screen image of the result, and paste it to the end of the report you...
write a C program that emulates you with the calculator which can operate with the four operations ( + - / * ) , the program should keep running and asks the user to end or continue use functions to create the calculator part
You need to write this program providing function definition. You can choose your own function definition. Write a program that will ask the user to provide an angle value and the program will calculate the sine, cosine and tangent of that angle. (in python)
Write a JavaFX program to display 5 labels and 3 buttons. You can use any kind of Pane you like to use. Display 3 red circles and 2 blue rectangles (pick your own size). Use the Image and ImageView classes (explained in section 14.9 of your textbook) to show 2 images of your choice. Include your first and last name somewhere on the frame, label, button, etc. We won’t discuss handing events where one would be able to click buttons...
Please, build calculator to exact image as below using
Python.
Write a GUI that implements the calculator shown in the following image: Calculator х Plus Equals: Add Clear Quit - User enters two integers into the text fields. - When Add button is pressed, the sum of the values in the text fields are shown after the Equals: as a label. - The Clear button clears the values in the text fields. The cleared values can be blank or zero....
Can you please use your own words thank you List and describe (in your own words) three of the crucial keys to development of an effective ethics program
would like you to think about where you can see the principles of scientific management at work in the world today. In your place of work? In schools, colleges, and other educational institutions? In restaurants, grocery stores, pharmacies, and other retail establishments? In your classroom? Give me a few examples of what you have encountered personally.
"The solar eclipse" passage. what can you assume from this flyer? what type of book would you use to see important dates from the solar eclipse?
describe the communication and stakeholder engagement methods you would use to build support for your health service or program among professionals? What methods would you use to support community engagement? What potential obstacles do you foresee in terms of implementation if communication and stakeholder engagement are absent?