当前位置:首页 » 编程软件 » 科学编程计算器

科学编程计算器

发布时间: 2022-10-20 02:53:28

1. 编程实现一个科学计算器,能够实现加减乘除,三角函数计算等。用户界面自己设计

java写的,可行

package ex1;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DecimalFormat;

import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JTextField;

public class Calcutor extends JFrame {
private JTextField tf;
private JPanel panel1, panel2, panel3, panel4;
private JMenuBar myBar;
private JMenu menu1, menu2, menu3;
private JMenuItem editItem1, editItem2, help1, help2, help3;
private JRadioButtonMenuItem seeItem1, seeItem2;//单选框
private JCheckBoxMenuItem seeItem3;//复选框
private ButtonGroup bgb;
private String back;
private boolean IfResult = true, flag = false;
private String oper = "=";
private double result = 0;
private Num numActionListener;
private DecimalFormat df;

public Calcutor(){
super("科学计算器");//设置标题栏

df = new DecimalFormat("#.####");//保留四位小数

this.setLayout(new BorderLayout(10, 5));
panel1 = new JPanel(new GridLayout(1, 3, 10, 10));
panel2 = new JPanel(new GridLayout(5, 6, 5, 5));//5行6列
panel3 = new JPanel(new GridLayout(5, 1, 5, 5));
panel4 = new JPanel(new BorderLayout(5, 5));

/**
* 菜单栏
*/
myBar = new JMenuBar();
menu1 = new JMenu("编辑(E)");
menu2 = new JMenu("查看(V)");
menu3 = new JMenu("帮助(H)");

menu1.setFont(new Font("宋体", Font.PLAIN, 12));
menu2.setFont(new Font("宋体", Font.PLAIN, 12));
menu3.setFont(new Font("宋体", Font.PLAIN, 12));

/**
* 编辑栏
*/
editItem1 = new JMenuItem("复制(C) Ctrl+C");
editItem2 = new JMenuItem("粘贴(P) Ctrl+V");

editItem1.setFont(new Font("宋体",Font.PLAIN,12));
editItem2.setFont(new Font("宋体",Font.PLAIN,12));

/**
* 查看栏
*/
seeItem1 = new JRadioButtonMenuItem("科学型(T)");
seeItem2 = new JRadioButtonMenuItem("标准型(S)");
seeItem3 = new JCheckBoxMenuItem("数字分组(I)");

seeItem1.setFont(new Font("宋体",Font.PLAIN,12));
seeItem2.setFont(new Font("宋体",Font.PLAIN,12));
seeItem3.setFont(new Font("宋体",Font.PLAIN,12));

/**
* 帮助栏
*/
help1 = new JMenuItem("帮助主题(H)");
help2 = new JMenuItem("关于计算器(A)");

help1.setFont(new Font("宋体",Font.PLAIN,12));
help2.setFont(new Font("宋体",Font.PLAIN,12));

bgb = new ButtonGroup();//选项组

menu1.add(editItem1);
menu1.add(editItem2);

menu2.add(seeItem1);
menu2.add(seeItem2);
menu2.addSeparator();//添加一条分割线
menu2.add(seeItem3);

menu3.add(help1);
menu3.addSeparator();//添加一条分割线
menu3.add(help2);

myBar.add(menu1);
myBar.add(menu2);
myBar.add(menu3);

this.setJMenuBar(myBar);

numActionListener = new Num();//实现数字监听

/**
* 文本域,即为计算器的屏幕显示区域
*/
tf = new JTextField();
tf.setEditable(false);//文本区域不可编辑
tf.setBackground(Color.white);//文本区域的背景色
tf.setHorizontalAlignment(JTextField.RIGHT);//文字右对齐
tf.setText("0");
tf.setBorder(BorderFactory.createLoweredBevelBorder());
init();//对计算器进行初始化

}
/**
* 初始化操作
* 添加按钮
*/
private void init(){
addButton(panel1, "Backspace", new Clear(), Color.red);
addButton(panel1, "CE", new Clear(), Color.red);
addButton(panel1, "C", new Clear(), Color.red);

addButton(panel2, "1/x", new Signs(), Color.magenta);
addButton(panel2, "log", new Signs(), Color.magenta);
addButton(panel2, "7", numActionListener, Color.blue);
addButton(panel2, "8", numActionListener, Color.blue);
addButton(panel2, "9", numActionListener, Color.blue);
addButton(panel2, "÷", new Signs(), Color.red);

addButton(panel2, "n!", new Signs(), Color.magenta);
addButton(panel2, "sqrt", new Signs(), Color.magenta);
addButton(panel2, "4", numActionListener, Color.blue);
addButton(panel2, "5", numActionListener, Color.blue);
addButton(panel2, "6", numActionListener, Color.blue);
addButton(panel2, "×", new Signs(), Color.red);

addButton(panel2, "sin", new Signs(), Color.magenta);
addButton(panel2, "x^2", new Signs(), Color.magenta);
addButton(panel2, "1", numActionListener, Color.blue);
addButton(panel2, "2", numActionListener, Color.blue);
addButton(panel2, "3", numActionListener, Color.blue);
addButton(panel2, "-", new Signs(), Color.red);

addButton(panel2, "cos", new Signs(), Color.magenta);
addButton(panel2, "x^3", new Signs(), Color.magenta);
addButton(panel2, "0", numActionListener, Color.blue);
addButton(panel2, "-/+", new Clear(), Color.blue);
addButton(panel2, ".", new Dot(), Color.blue);
addButton(panel2, "+", new Signs(), Color.red);

addButton(panel2, "tan", new Signs(), Color.magenta);
addButton(panel2, "%", new Signs(), Color.magenta);
addButton(panel2, "π", numActionListener, Color.orange);
addButton(panel2, "e", numActionListener, Color.orange);
addButton(panel2, "′″", new Signs(), Color.orange);
addButton(panel2, "=", new Signs(), Color.red);

JButton btns = new JButton("计算器");
btns.setBorder(BorderFactory.createLoweredBevelBorder());
btns.setEnabled(false);//按钮不可操作
btns.setPreferredSize(new Dimension(20, 20));

panel3.add(btns);//加入按钮
addButton(panel3, "MC", null, Color.red);
addButton(panel3, "MR", null, Color.red);
addButton(panel3, "MS", null, Color.red);
addButton(panel3, "M+", null, Color.red);

panel4.add(panel1, BorderLayout.NORTH);
panel4.add(panel2, BorderLayout.CENTER);
this.add(tf, BorderLayout.NORTH);
this.add(panel3, BorderLayout.WEST);
this.add(panel4);

pack();
this.setResizable(false);//窗口不可改变大小
this.setLocation(300, 200);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
/**
* 统一设置按钮的的使用方式
* @param panel
* @param name
* @param action
* @param color
*/
private void addButton(JPanel panel, String name, ActionListener action, Color color){
JButton bt = new JButton(name);
panel.add(bt);//在面板上增加按钮
bt.setForeground(color);//设置前景(字体)颜色
bt.addActionListener(action);//增加监听事件
}
/**
* 计算器的基础操作(+ - × ÷)
* @param x
*/
private void getResult (double x){
if(oper == "+"){result += x;}
else if(oper == "-"){result -= x;}
else if(oper == "×"){result *= x;}
else if(oper == "÷"){result /= x;}
else if(oper == "="){result = x;}
tf.setText(df.format(result));
}
/**
* 运算符号的事件监听
*/
class Signs implements ActionListener{
public void actionPerformed(ActionEvent e) {
/*
* 用ActionEvent对象的getActionCommand()方法
* 取得与引发事件对象相关的字符串
*/
String str = e.getActionCommand();

/* sqrt求平方根 */
if(str.equals("sqrt")){
double i = Double.parseDouble(tf.getText());
if(i>=0){
/*
* String.valueOf() 转换为字符串
* df.format() 按要求保留四位小数
* Math.sqrt() 求算数平方根
*/
tf.setText(String.valueOf(df.format(Math.sqrt(i))));
}
else{
tf.setText("负数不能开平方根");
}
}

/* log求常用对数 */
else if(str.equals("log")){
double i = Double.parseDouble(tf.getText());
if(i>0){
tf.setText(String.valueOf(df.format(Math.log(i))));
}else{
tf.setText("负数不能求对数");
}
}

/* %求百分比 */
else if(str.equals("%")){
tf.setText(df.format(Double.parseDouble(tf.getText()) / 100));
}

/* 1/x求倒数 */
else if(str.equals("1/x")){
if(Double.parseDouble(tf.getText()) == 0){
tf.setText("除数不能为零");
}else{
tf.setText(df.format(1 / Double.parseDouble(tf.getText())));
}
}

/* sin求正弦函数 */
else if(str.equals("sin")){
double i = Double.parseDouble(tf.getText());
tf.setText(String.valueOf(df.format(Math.sin(i))));
}

/* cos求余弦函数 */
else if(str.equals("cos")){
double i = Double.parseDouble(tf.getText());
tf.setText(String.valueOf(df.format(Math.cos(i))));
}

/* tan求正切函数 */
else if(str.equals("tan")){
double i = Double.parseDouble(tf.getText());
tf.setText(String.valueOf(df.format(Math.tan(i))));
}

/* n!求阶乘 */
else if(str.equals("n!")){
double i = Double.parseDouble(tf.getText());
if((i%2==0)||(i%2==1))//判断为整数放进行阶乘操作
{
int j = (int)i;//强制类型转换
int result=1;
for(int k=1;k<=j;k++)
result *= k;
tf.setText(String.valueOf(result));
}
else
{
tf.setText("无法进行阶乘");
}
}

/* x^2求平方 */
else if(str.equals("x^2")){
double i = Double.parseDouble(tf.getText());
tf.setText(String.valueOf(df.format(i*i)));
}

/* x^3求立方 */
else if(str.equals("x^3")){
double i = Double.parseDouble(tf.getText());
tf.setText(String.valueOf(df.format(i*i*i)));
}

/* ′″角度转换 */
/**
* 将角度值转换成弧度值,方便三角函数的计算
*/
else if(str.equals("′″")){
double i = Double.parseDouble(tf.getText());
tf.setText(String.valueOf(i/180*Math.PI));
}

else{
if(flag){
IfResult = false;
}
if(IfResult){
oper = str;
}else{
getResult(Double.parseDouble(tf.getText()));
oper = str;
IfResult = true;
}
}
}
}
/**
* 清除按钮的事件监听
*/
class Clear implements ActionListener{
public void actionPerformed(ActionEvent e) {
/*
* 用ActionEvent对象的getActionCommand()方法
* 取得与引发事件对象相关的字符串
*/
String str = e.getActionCommand();
if(str == "C"){
tf.setText("0");
IfResult = true;
result = 0;
}else if(str == "-/+"){
double i = 0 - Double.parseDouble(tf.getText().trim());
tf.setText(df.format(i));
}else if(str == "Backspace"){
if(Double.parseDouble(tf.getText()) > 0){
if(tf.getText().length() > 1){
tf.setText(tf.getText().substring(0, tf.getText().length() - 1));
//使用退格删除最后一位字符
}else{
tf.setText("0");
IfResult = true;
}
}else{
if(tf.getText().length() > 2){
tf.setText(tf.getText().substring(0, tf.getText().length() - 1));
}else{
tf.setText("0");
IfResult = true;
}
}
}else if(str == "CE"){
tf.setText("0");
IfResult = true;
}
}
}
/**
* 数字输入的事件监听
*/
class Num implements ActionListener{
public void actionPerformed(ActionEvent e) {
String str = e.getActionCommand();
if(IfResult){
tf.setText("");
IfResult = false;
}
if(str=="π")
{
tf.setText(String.valueOf(Math.PI));
}
else if(str=="e")
{
tf.setText(String.valueOf(Math.E));
}
else{
tf.setText(tf.getText().trim() + str);
if(tf.getText().equals("0")){
tf.setText("0");
IfResult = true;
flag = true;
}
}
}
}
/**
* 小数点的事件监听
*/
class Dot implements ActionListener{
public void actionPerformed(ActionEvent e) {
IfResult = false;
if(tf.getText().trim().indexOf(".") == -1){
tf.setText(tf.getText() + ".");
}
}
}
/**
* main方法
*/
public static void main(String[] args) {
new Calcutor().setVisible(true);
}
}

2. 什么是编程计算器

非编程的只有简单的函数功能。编程计算器,支持变量定义,临时结果存储等,支持变量拖放操作,程序步数高达4000步以上,具备常用科学函数,程序计算速度极快。支持叠代运算,可以用于日常复杂的计算以及工程运算。

为了解决使用机器语言编写应用程序所带来的一系列问题,人们首先想到使用助记符号来代替不容易记忆的机器指令,这种助记符号来表示计算机指令的语言称为符号语言,也称汇编语言。

在汇编语言中,每一条用符号来表示的汇编指令与计算机机器指令一一对应;记忆难度大大减少了,不仅易于检查和修改程序错误,而且指令、数据的存放位置可以由计算机自动分配。



(2)科学编程计算器扩展阅读:

使用汇编语言编写计算机程序,程序员仍然需要十分熟悉计算机系统的硬件结构,所以从程序设计本身上来看仍然是低效率的、繁琐的。

但正是由于汇编语言与计算机硬件系统关系密切,在某些特定的场合,如对时空效率要求很高的系统核心程序以及实时控制程序等,迄今为止汇编语言仍然是十分有效的程序设计工具。

但它有不可替代的特性,比如一些单片机或者一些直接控制硬件的程序就一定要用汇编语言。

3. 科学计算器和函数计算器的区别

函数科学计算器主要是给学生使用的,包括小学高年级,初中高中和大学,主要完成的部分是基本代数计算,统计计算,回归计算,简单的方程,矩阵和函数赋值等功能,和课本上的指示类似,例如82ES 991ES。高级的图形科学计算器带编程和函数图像功能 ,例如9750,9860等。函数工程计算器主要是面向工程师的,除了基本的功能,都带有编程(以工程为主)功能,26个变量和数据传递功能,例如5800等

4. 科学计算器怎么编程

如果你说的是电脑系统中自带的科学计数器的话,那东西没有编程功能,只有对不同进制的数进行辅助计算的功能,如果是其他的计算器可以查看产品说明书或网络相关资料。

5. 用可编程科学计算器,怎样编写灰色预测模型GM(1,1)程序

分享兴趣,传播快乐,增长见闻,留下美好!亲爱的您,这里是LearningYard学苑。

今天小编为大家带来《快速上手灰色系统理论GM(1,1)模型》,一起来看看吧!

快速上手灰色系统理论GM(1,1)模型
01:53来自LearningYard学苑

多图预警!建议连接WIFI阅读!

【1】研究背景

灰色系统理论是由我国着名学者邓聚龙教授创立,是中国原创学科,是确定性理论和系统科学领域的重要学科。我们称部分信息已知,部分信息不明确的系统为灰色系统,通过对少量信息的累加、累减等计算处理,获取有价值的部分,实现对灰色系统变化趋势的预测,或者对当前系统状况的准确监控。如今灰色系统理论已经进过了将近40年的发展完善,成果丰硕,在理论体系和模型框架方面已经比较完善,参数优化和计算方法等方面都有了相当大的改进,已形成包含了系统分析、预测、优化等技术体系,在许多学科领域得到了广泛的应用。
GM(1,1)模型作为灰色系统理论重要组成部分,适合于小样本数据的预测,在样本缺乏导致信息不足的情况下能充分利用所观察到的决策信息,给出较高精度的预测结果。GM(1,1)模型的思想是对最开始的数据进行一次累加生成数据序列,新的数据序列相应的曲线可以应用特定曲线无限逼近,把逼近曲线作为基础模型,将预测值做几次滚动累加还原,以预测出发展趋势。

【2】基础概念

(1)灰色系统

灰色系统介于黑色系统与白色系统之间,称部分信息已知、另部分信息未知,且内部各因素间有不确定的关系的系统为灰色系统。

(2)灰色预测

灰色预测是通过少量的、不完全的信息,建立数学模型做出预测的一种预测方法。该方法基于客观事物的过去和现在的发展规律,对未来的发展趋势和状况进行描述和分析,并形成科学的假设和判断。其中GM(1,1)模型就是灰色预测中的强力工具之一。

(3)GM(1,1)模型

该模型中,G表示Grey,M表示Model,括号中第一个1代表一阶微分方程,第二个1代表微分方程有一个变量。同理,灰色预测理论中GM(1,2)表示有两个变量的一阶微分方程灰色模型。

【3】基于GM(1,1)模型的灰色预测步骤

令不完全信息非负序列为X(0),生成1-AGO(1-Accumulating Generation Operational)序列X(1)。1-AGO序列类似帕累托图中的累加折线。

利用高数知识构建GM(1,1)模型的灰色微分方程,其中a为发展系数,b为灰色作用量。通过公式得到均值形式的GM(1,1)模型Z(1)。

构建灰色预测矩阵:

通过最小二乘法构建函数,并求出估计值:

GM(1,1)模型的白化微分方程为:

得到在公式(1)条件下时间响应函数,并对公式(7)进行计算,得到模拟预测序列。

【英语学习】

Grey system theory was founded by the famous Chinese scholar Professor Deng Julong. It is an original subject in China and an important subject in the field of deterministic theory and systems science. We call a system with some known information and some unclear information as a gray system. By accumulating and subtracting a small amount of information, we can obtain valuable parts to predict the changing trend of the gray system or the current system status. Accurate monitoring. Now the grey system theory has been developed and perfected for nearly 40 years, with fruitful results. It has been relatively complete in terms of theoretical system and model framework, and considerable improvements have been made in parameter optimization and calculation methods, and it has been formed to include system analysis. Technical systems such as, forecasting, and optimization have been widely used in many disciplines. As an important part of gray system theory, GM(1,1) model is suitable for the prediction of small sample data. It can make full use of the observed decision information when the lack of samples leads to insufficient information, and give high-precision prediction results . The idea of the GM(1,1) model is to accumulate the initial data once to generate a data sequence. The corresponding curve of the new data sequence can be approximated infinitely by a specific curve. The approximate curve is used as the basic model and the predicted value is rolled several times. Accumulate rection to predict the development trend.

本期的分享就到这里,如果您对今天的文章有独特的想法,欢迎给我们留言,让我们相约明天,祝您今天过得开心快乐!

本文由LearningYard学苑原创,仅代表作者个人观点,如有侵权请联系删除。

翻译参考来源:Google翻译。

内容参考来源:

[1] Liu S , Yin C , Cao D . Weapon equipment management cost prediction based on forgetting factor recursive GM (1,1) model[J]. Grey Systems Theory & Application, 2019, 10(1):38-45.

6. 计算机上面的 科学计算器怎么设置

这是科学计算法的结果,数学中我们可以叫做指数。

通过结果我们可以得知这是1.0689……×10的-37次方,计算的结果也就是1.0689的小数点往前移37位,0.000000……151。

1、点击开始——所有程序——附件——计算器打开即可。

打开计算器程序后,我们可以看到常用的页面显示出来了,那么下面我们来设置科学计算器,找到上方的“查看”功能并打开选择“科学型”。

e-37表示n(10)得-37次方,e37表示n(10)得37次方。e一般在编程中表示科学计算法,我们经常说得win7,win10也是编程所编写得。

7. 手机上的科学计算器度分秒怎么输入

科学计算器键盘一般不能直接输入度或分或秒,这是因为它内部使用的是弧度制,所以在计算之前,需要将度分秒转化为对应的弧度,再进行计算。为计算的更加方便,可以下载功能强大的科学计算器。

第1,在手机上安装名称叫作易历知食的软件。
第2,打开该软件,点左下角的“开始”,再点“应用程序”,再点“可编程计算器”,此时计算器已经打开,可以进行计算了。第3,将度分秒转化为弧度。
这里展示两种方式:方式一,使用计算器内置的rad角度转换函数来直接计算
方式二,使用计算器内置的rad角度转换函数并结合编程来计算(这种方式可以计算复杂的问题),先点击“编程区”,并输入角度转换的变量(d表示度对应的弧度,f表示分对应的弧度,m表示秒对应的弧度),之后计算
计算器中输入度分秒方法:百
具体步骤如下(以输入度30度24分32秒为例):
首先输入
输入30,按“。,,,“键(该键左上角标记FACT,右上角标记B,以fx-82ES机型为主)表问示30度;
然后输入24,再按“。,,,“键;
最后输入32,按“。,,,“键。
注:答如果是30度零32秒,需要输入0分,即输入的应该是30度0分32秒;如果是30度24分,则只需要进专行到上述第二部即可!

热点内容
破解exe加密视频 发布:2025-05-17 11:23:41 浏览:976
我的世界服务器圈太大了怎么办 发布:2025-05-17 11:15:21 浏览:614
便宜的免费云服务器 发布:2025-05-17 11:08:50 浏览:776
中国顶级dhcp解析服务器地址 发布:2025-05-17 11:06:27 浏览:34
php转义html 发布:2025-05-17 11:04:00 浏览:567
钢筋笼加密区规范 发布:2025-05-17 10:59:50 浏览:4
我的世界网易手机版主播服务器房号 发布:2025-05-17 10:40:59 浏览:227
竖编译 发布:2025-05-17 09:56:08 浏览:229
编程画飞机 发布:2025-05-17 09:54:03 浏览:803
手机如何解锁密码屏幕锁怎么删除 发布:2025-05-17 09:52:04 浏览:125