Make sure to write in Dr Java *In DR JAVA* Objective: Create a scientific calcul
ID: 3720209 • Letter: M
Question
Make sure to write in Dr Java
*In DR JAVA* Objective: Create a scientific calculator. It should behave like any other scientific calculator where the user presses keys and stuff happens. This must have a graphical user interface (GUI), and include the following features Current total display Number pad Arithmetic functions o Addition o Subtraction o Multiplication o Division o You may disregard order of operations Trigonometric functions o Sine o Cosine o Tangent o Arcsine o Arctangent . Additional mathematic functions o Exponent o Square root o Logarithm Additional functions o Clear- Zeroes out the current total o Equals - Gives the running total Furthermore every time a user enters a number first it should set the running total to said number. If an operation is entered then that operation is applied to the current total. If it is a binary operation like addition, subtraction, multiplication, division, and exponent then the following number will be the second number in that function, and applied as soon as the user presses equals.Explanation / Answer
import java.awt.*; import javax.swing.*; import java.awt.event.*; import javax.swing.event.*; public class ScientificCalculator extends JFrame implements ActionListener { JTextField tfield; double temp, temp1, result, a; static double m1, m2; int k = 1, x = 0, y = 0, z = 0; char ch; JButton b1, b2, b3, b4, b5, b6, b7, b8, b9, zero, clr, pow2, pow3, exp, fac, plus, min, div, log, rec, mul, eq, addSub, dot, mr, mc, mp, mm, sqrt, sin, cos, tan; Container cont; JPanel textPanel, buttonpanel; ScientificCalculator() { cont = getContentPane(); cont.setLayout(new BorderLayout()); JPanel textpanel = new JPanel(); tfield = new JTextField(25); tfield.setHorizontalAlignment(SwingConstants.RIGHT); tfield.addKeyListener(new KeyAdapter() { public void keyTyped(KeyEvent keyevent) { char c = keyevent.getKeyChar(); if (c >= '0' && cRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.