Java程序设计之简单计算器

问题描述:请使用Java编程语言设计一个简易计算器,能够实现基本的运算功能。Java程序源码:import java.awt.*;import java.awt.event.*;import javax.swing.*;class simplecalculator { static String point=new String(); static String Amal=...
摘要由CSDN通过智能技术生成

问题描述:请使用Java编程语言设计一个简易计算器,能够实现基本的运算功能。

Java程序源码:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

class simplecalculator 
{
	static String point=new String();
	static String Amal=new String();
	static String ONE=new String();
	static String TWO=new String();
	static String THREE=new String();
	static String FOUR=new String();
	static String FIVE=new String();
	static String SIX=new String();
	static String SEVEN=new String();
	static String EIGHT=new String();
	static String NINE=new String();
	static String ZERO=new String();
	static String ResultState=new String();

	static Double QF;
	static JButton zero=new JButton("0");
	static JButton one=new JButton("1");
	static JButton two=new JButton("2");
	static JButton three=new JButton("3");
	static JButton four=new JButton("4");
	static JButton five=new JButton("5");
	static JButton six=new JButton("6");
	static JButton seven=new JButton("7");
	static JButton eight=new JButton("8");
	static JButton nine=new JButton("9");
	static JButton add=new JButton("+");
	static JButton sub=new JButton("-");
	static JButton mul=new JButton("*");
	static JButton div=new JButton("/");
	static JButton QuFan=new JButton("+/-");
	static JButton Dian=new JButton(".");
	static JButton equal=new JButton("=");
	static JButton clear=new JButton("C");
	static JButton BaiFen=new JButton("%");
	static JButton FenZhiYi=new JButton("1/x");
	static int i=0;
	static Double addNumber;
	static Double subNumber;
	static Double mulNumber;
	static Double divNumber;
	static Double equalNumber;
	static Double temp;
	static JTextArea result=new JTextArea(1,20);
	
	public static void main(String[] args)
	{
	JFrame frame=new JFrame("计算器");
	result.setEditable(false);
	result.setText("");
	ResultState="窗口空";
	JPanel ForResult=new JPanel();
	JPanel ForButton7_clear=new JPanel();
	JPanel ForButton4_mul=new JPanel();
	JPanel ForButton1_sub=new JPanel();
	JPanel ForButton0_equal=new JPanel();
	
	FlowLayout FLO=new FlowLayout();
	ForResult.add(result);
	
	ForButton7_clear.setLayout(FLO);
	ForButton7_clear.add(seven);
	ForButton7_clear.add(eight);
	ForButton7_clear.add(nine);
	ForButton7_clear.add(div);
	ForButton7_clear.add(clear);
	
	ForButton4_mul.setLayout(
  • 6
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

技术小咖龙

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值