⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 calc.java

📁 This Project Contain Calculator
💻 JAVA
字号:
import java.lang.*;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.util.*;
import java.math.*;
/*<applet code="calc" width=1000 height=1000>
</applet>
*/
public class calc extends Applet implements Runnable, ActionListener
{
	int Counter;			//counts the number of digits entered

	double Result;			//the answer displayed, as well as the second 
							//operator taken for an operation

	double Operand;			//the first number entered for an operation
	
	double Mem;				//the variable which holds whatever value the user 
							//wants kept in "memory"
	
	boolean DecimalFlag;	//the 'flag' that will signify whether or not the 
							//decimal button has been pressed
	
	boolean SignFlag;		//the 'flag' that will signify whether or not the 
							//plus/minus button has been pressed
	
	boolean OperatorKey;	//the 'flag' that will signify whether or not any 
							//operator button has been pressed
	
	boolean FunctionKey;	//the 'flag' that will signify whether or not any f
							//function button has been pressed
	
	int Operator;			//an integer value to indicate which operator
							//button was pressed
	
	char currchar;			//a character to hold the value of the key most 
							//recently pressed
	
	String GrStatus;		//String to hold the status of various graphic
							//operations of the program
	
	String Status;			//String to hold the status of various parts 
							//of the program

	Thread timer;			//A thread that will count how long user has been
							//working with the calculator
		
	int secs = 0;			//counts seconds, used by Thread timer
	int mins = 0;			//counts minutes, used by Thread timer
	int hrs  = 0;			//counts hours, used by Thread timer
	
	//A string to hold the currentCount as indicated by the above variables
	String currentCount = "Count started...";
	
	//A Label that will display the current count on the calculator
	Label CountTimer = new Label(" ",Label.LEFT);
	
	//A string to hold the currentTime as indicated by the above variables
	String currentTime = "Current Time";

	//A Canvas that will display the current time on the calculator
	Canvas currTime;
	
	//This label will display all error messages
	Label DisplError = new Label(" ",Label.CENTER);
	
	/* This label is just to the left of the Display Label lcdDisplay, and will 
	 * indicate whether or not a value is being held in the calculator's "memory"
	 */
	Label LabelMem = new Label(" ",Label.RIGHT);

	/* This is the Display Label, which is declared as a label so the user will not 
	 * be able to enter any text into it to possibly crash the calculator
	 */
	Label lcdDisplay = new Label("0",Label.RIGHT);
	
	// This is the declaration of all numeric buttons to be used in the applet
	 
	Button button1 = new Button("1");
	Button button2 = new Button("2");
	Button button3 = new Button("3");
	Button button4 = new Button("4");
	Button button5 = new Button("5");
	Button button6 = new Button("6");
	Button button7 = new Button("7");
	Button button8 = new Button("8");
	Button button9 = new Button("9");
	Button button0 = new Button("0");

	/* This is the declaration of all operation buttons that are used in applet. 
	 * MPlus, MClear and MR are all memory functions.
	 */
	Button buttonMinus    = new Button("-");
	Button buttonMultiply = new Button("x");
	Button buttonPlus     = new Button("+");
	Button buttonEquals   = new Button("=");
	Button buttonDivide   = new Button("

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -