Access Millions of academic & study documents

Java Code for Calculator Using AWT Components Lab Report

Content type
User Generated
Subject
Computer Science
Type
Lab Report
Showing Page:
1/7

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/7

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/7

Sign up to view the full document!

lock_open Sign Up
End of Preview - Want to read all 7 pages?
Access Now
Unformatted Attachment Preview
OOP ASSINGMENT NO 4 18-SE-45 ABDUL ALI Question: Write a java code for calculator Using AWT Components. Code: import java.awt.*; import java.awt.event.*; /*********************************************/ public class MyCalculator extends Frame { public boolean setClear=true; double number, memValue; char op; String digitButtonText[] = {"7", "8", "9", "4", "5", "6", "1", "2", "3", "0", "+/-", "." }; String operatorButtonText[] = {"/", "sqrt", "*", "%", "-", "1/X", "+", "=" }; String memoryButtonText[] = {"MC", "MR", "MS", "M+" }; String specialButtonText[] = {"Backspc", "C", "CE" }; MyDigitButton digitButton[]=new MyDigitButton[digitButtonText.length]; MyOperatorButton operatorButton[]=new MyOperatorButton[operatorButtonText.length]; MyMemoryButton memoryButton[]=new MyMemoryButton[memoryButtonText.length]; MySpecialButton specialButton[]=new MySpecialButton[specialButtonText.length]; Label displayLabel=new Label("0",Label.RIGHT); Label memLabel=new Label(" ",Label.RIGHT); final int FRAME_WIDTH=325,FRAME_HEIGHT=325; final int HEIGHT=30, WIDTH=30, H_SPACE=10,V_SPACE=10; final int TOPX=30, TOPY=50; /////////////////////////// MyCalculator(String frameText)//constructor { super(frameText); int tempX=TOPX, y=TOPY; displayLabel.setBounds(tempX,y,240,HEIGHT); displayLabel.setBackground(Color.BLUE); displayLabel.setForeground(Color.WHITE); add(displayLabel); memLabel.setBounds(TOPX, TOPY+HEIGHT+ V_SPACE,WIDTH, HEIGHT); add(memLabel); // set Co-ordinates for Memory Buttons tempX=TOPX ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.
Studypool
4.7
Indeed
4.5
Sitejabber
4.4

Similar Documents