Using Java language 1. Purpose of the programming : [Integer calculator Program
ID: 3680469 • Letter: U
Question
Using Java language
1. Purpose of the programming : [Integer calculator Program based on GUI] You will write a calculator program for integer numbers for this homework
The calculator should be able to do addition, subtraction, multiplication, and division for integer numbers. The calculator will take receive an equation composed of +, -, *, /, and several integers through GUI, and its result is outputted over the GUI.
2. Requirements of input Possible operators are addition(+), subtraction(-), multiplication(*), and division(/). And, parentheses (‘(‘,’)’) is also possible.
Integers as operands should be positive. Negative integer can be represented in the form of ( 0 – positive number ). For example, -4 is represented as ( 0 – 4 ). Likewise -8 as ( 0 – 8 ) There should exist at least one blank (‘ ‘) between every integer, operator, and parenthesis.
Correct example: ( 2 + 4 ) * 5
Wrong example : (2+4) * 5
Explanation / Answer
Hi below I have written the following code for your reference, import java.awt.*; import java.awt.event.*; import java.applet.*; /* */ public class Cal extends Applet implements ActionListener { String msg=" "; int v1,v2,result; TextField t1; Button b[]=new Button[10]; Button add,sub,mul,div,clear,mod,EQ; char OP; public void init() { Color k=new Color(120,89,90); setBackground(k); t1=new TextField(10); GridLayout gl=new GridLayout(4,5); setLayout(gl); for(int i=0;iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.