1.[源码和文档分享]基于C++实现的安卓安装多项式计算器系统
2.求基于Java开发的多功能计算器源码,要有注释的计算,谢谢!器源
3.急:求一个简单的码下日采集源码JAVA计算器代码,简单点,载安卓计有图形界面的算器
[源码和文档分享]基于C++实现的多项式计算器系统
实验目的是通过C++语言实现一个多项式计算器系统,以提升编程技能和理解运算符重载与类设计。源码
实验环境要求使用C++作为编程语言,下载并选择合适的安卓安装开发工具,同时需遵循良好的计算程序设计风格。基本编码规范包括简洁性、器源mysql源码安装cmake可读性、码下可维护性,载安卓计如使用有意义的算器变量名、合理的源码注释、避免代码冗余等。传奇3源码调试
实验内容涉及设计并实现一个多项式计算器系统。利用C++的类及运算符重载特性,编写源代码,最终生成可执行程序,以实现对简单多项式的obs直播平台源码计算操作。
实现步骤如下:
1. 定义多项式类,包含多项式的系数和指数,并实现运算符重载以支持多项式的加、减、乘、家装网装修平台源码除等基本运算。
2. 设计用户接口,允许用户输入多项式表达式,并能够输出计算结果。
3. 编写测试函数,确保多项式类和用户接口的正确性。
实验过程中需参考文档,以获取详细指导和实现细节。完整的文档和源码下载地址如下:
write-bug.com/article/1...
通过本实验,学员将深入理解C++类设计、运算符重载等核心概念,同时获得一个实际的多项式计算器系统实例,提升编程实践能力。
求基于Java开发的多功能计算器源码,要有注释的,谢谢!
import java.awt.*;
import java.awt.event.*;
public class Calculator extends WindowAdapter implements ActionListener
{
private double result=0,data1=0,radixPointDepth=1;
private boolean radixPointIndicate=false,resultIndicate=false;
private char prec='+';
private Frame f;
private TextField tf;
private Button b1,b2,b3,b4,b5,b6,b7,b8,b9,b,b,b,b,b,b,b,b;
private Panel p;
static public void main(String args[])
{
Calculator de=new Calculator();
de.go();
}
public void go()
{
f=new Frame("计算器");
p=new Panel();
p.setLayout(new GridLayout(4,4));
tf=new TextField();
b1=new Button("7");
b2=new Button("8");
b3=new Button("9");
b4=new Button("+");
b5=new Button("4");
b6=new Button("5");
b7=new Button("6");
b8=new Button("-");
b9=new Button("1");
b=new Button("2");
b=new Button("3");
b=new Button("*");
b=new Button("0");
b=new Button(".");
b=new Button("=");
b=new Button("/");
b=new Button("清零");
f.add(tf,"North");
f.add(p,"Center");
f.add(b,"South");
p.add(b1);
p.add(b2);
p.add(b3);
p.add(b4);
p.add(b5);
p.add(b6);
p.add(b7);
p.add(b8);
p.add(b9);
p.add(b);
p.add(b);
p.add(b);
p.add(b);
p.add(b);
p.add(b);
p.add(b);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
b6.addActionListener(this);
b7.addActionListener(this);
b8.addActionListener(this);
b9.addActionListener(this);
b.addActionListener(this);
b.addActionListener(this);
b.addActionListener(this);
b.addActionListener(this);
b.addActionListener(this);
b.addActionListener(this);
b.addActionListener(this);
b.addActionListener(this);
f.addWindowListener(this);
f.setSize(,);
f.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
String s;
s=e.getActionCommand();
switch(s.charAt(0))
{
case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
if(resultIndicate)
{
result=0;
data1=0;
prec='+';
}
Integer Int1=new Integer(s);
if(radixPointIndicate)
{
radixPointDepth=radixPointDepth/;
data1=data1+(Int1.intValue())*radixPointDepth;
}
else
{
data1=data1*+(Int1.intValue());
}
Double displayNumber=new Double(data1);
tf.setText(displayNumber.toString());
resultIndicate=false;
break;
case '+': case '-':case '*':case '/':case '=':
if(s.charAt(0)!='='&&resultIndicate)
{
prec=s.charAt(0);
resultIndicate=false;
}
else
{
switch(prec)
{
case '+':
result=result+data1;
break;
case '-':
result=result-data1;
break;
case '*':
result=result*data1;
break;
case '/':
result=result/data1;
break;
}
}
radixPointIndicate=false;
radixPointDepth=1;
displayNumber=new Double(result);
tf.setText(displayNumber.toString());
if(s.charAt(0)!='=')
{
data1=0;
prec=s.charAt(0);
}
else
{
resultIndicate=true;
}
break;
case '.':
radixPointIndicate=true;
break;
}
if(s.equals("清零"))
{
result=0;
data1=0;
radixPointDepth=1;
tf.setText("");
}
}
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
急:求一个简单的JAVA计算器代码,简单点,有图形界面的
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextField;
class Stack_Float
{
float nums[];
int top;
Stack_Float()
{
nums = new float[];
top = -1;
}
boolean IsEmpty()
{
if (top == -1)
return true;
else
return false;
}
float Pop_Stack()
{
if (top == -1)
{
return 0;
}
top--;
return nums[top + 1];
}
float GetTop()
{
return nums[top];
}
void Push_Stack(float num)
{
if (top == )
return;
top++;
nums[top] = num;
}
}
class Stack_Char
{
char str[];
int top;
Stack_Char()
{
str = new char[];
top = -1;
}
boolean CanPush(char c)
{
int temp = top;
if (c == '(')
{
while (temp != -1)
{
if (str[temp] == '(')
{
return false;
}
temp--;
}
}
temp = top;
if (c == '[')
{
while (temp != -1)
{
if (str[temp] == '[' || str[temp] == '(')
{
return false;
}
temp--;
}
}
if (c == '{ ')
{
while (temp != -1)
{
if (str[temp] == '{ ' || str[temp] == '[' || str[temp] == '(')
{
return false;
}
temp--;
}
}
return true;
}
boolean IsEmpty()
{
if (top == -1)
return true;
else
return false;
}
void Push_Stack(char ch)
{
if (top == )
return;
top++;
str[top] = ch;
}
char Pop_Stack()
{
if (top == -1)
return '\0';
top--;
return str[top + 1];
}
char GetTop()
{
if (top == -1)
{
System.out.print("error");
System.exit(0);
}
return str[top];
}
}
public class jisuanqi extends javax.swing.JFrame implements ActionListener
{
JTextField text = new JTextField();
JTextField text1 = new JTextField();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JButton jButton3 = new JButton();
JButton jButton4 = new JButton();
JButton jButton5 = new JButton();
JButton jButton6 = new JButton();
JButton jButton7 = new JButton();
JButton jButton8 = new JButton();
JButton jButton9 = new JButton();
JButton jButton = new JButton();
JButton jButton = new JButton();
JButton jButton = new JButton();
JButton jButton = new JButton();
JButton jButton = new JButton();
JButton jButton = new JButton();
JButton jButton = new JButton();
JButton jButton = new JButton();
JButton jButton = new JButton();
JButton jButton = new JButton();
JButton jButton = new JButton();
JButton jButton = new JButton();
JButton jButton = new JButton();
String show = "";
public jisuanqi()
{
initComponents();
}
char[] TranSmit(char str[])
{
char houzhui[] = new char[]; // 存放后缀表达式的字符串
int i = 0, j = 0;
char c = str[i];
Stack_Char s = new Stack_Char(); // 存放运算符的栈
while (c != '=') // 对算术表达式扫描未结束时
{
if (c >= '0' && c <= '9')
{
while (c >= '0' && c <= '9')// 数字直接入栈
{
houzhui[j] = c;
j++;
i++;
c = str[i];
}
houzhui[j] = '#';// 用#隔开数字
j++;
}
switch (c) // 扫描到运算符时
{
case '+':
case '-':
case '*':
case '/':
case '(':
case '[':
case '{ ':
if (s.IsEmpty() == true) // 栈空,直接入栈
{
s.Push_Stack(c);
i++;
c = str[i];
break;
}
if (ComPare(s.GetTop(), c) == -1) {
s.Push_Stack(c); // 入栈
i++;
c = str[i];
break;
}
if (ComPare(s.GetTop(), c) == 1) {
houzhui[j] = s.Pop_Stack();// 出栈元素存入后缀表达式
j++;
break;
}
case ')': // 扫描到 )
while (s.GetTop() != '(') // 未扫描到 ( 时,出栈
{
houzhui[j] = s.Pop_Stack();
j++;
}
s.Pop_Stack(); // '(' 出栈
i++;
c = str[i];
break;
case ']': // 扫描到 ]
while (s.GetTop() != '[') // 未扫描到 [ 时,出栈
{
houzhui[j] = s.Pop_Stack();
j++;
}
s.Pop_Stack(); // '[' 出栈
i++;
c = str[i];
break;
case '}': // 扫描到 }
while (s.GetTop() != '{ ') // 未扫描到 { 时,出栈
{
houzhui[j] = s.Pop_Stack();
j++;
}
s.Pop_Stack(); // '{ ' 出栈
i++;
c = str[i];
break;
}
}
while (s.IsEmpty() != true)// 把剩余的运算符直接出栈
{
houzhui[j] = s.Pop_Stack();
j++;
}
houzhui[j] = '=';// 后缀表达式后面加 =
j++;
houzhui[j] = '\0';
j++;
return houzhui;
}
float Count(char str[])
{
Stack_Float s = new Stack_Float();// 定义存放数字的栈
char c = str[0];
int i = 0;
float result = 0, temp, left, right;
while (c != '=') // 未扫描到 = 时
{
if (c >= '0' && c <= '9')// 扫描到数字
{
temp = 0;
while (c != '#')// 未读到分隔符时
{
temp = temp * + c - '0';
i++;
c = str[i];
}
s.Push_Stack(temp);// 进栈
}
switch (c)// 扫描到运算符时
{
case '+':
{
result = s.Pop_Stack() + s.Pop_Stack();// 2个数字出栈相加
s.Push_Stack(result);// 最后得数进栈
break;
}
case '-':
{
right = s.Pop_Stack();// 右操作数出栈
left = s.Pop_Stack();// 左操作数出栈
result = left - right;
s.Push_Stack(result);
break;
}
case '*':
{
result = s.Pop_Stack() * s.Pop_Stack();// 2个数字出栈相乘
s.Push_Stack(result);
break;
}
case '/':
{
right = s.Pop_Stack();// 右操作数出栈
left = s.Pop_Stack();// 左操作数出栈
result = left / right;
s.Push_Stack(result);
break;
}
}
i++;
c = str[i];
}
return result;
}
int ComPare(char a, char b) // 判断运算符的优先级函数
{
int s[][] = { // 栈顶元素高于算术表达式中的元素时, 返回 1,否则返回 -1
{ 1, 1, -1, -1, -1, 1, -1, 1, -1, 1 },
{ 1, 1, -1, -1, -1, 1, -1, 1, -1, 1 },
{ 1, 1, 1, 1, -1, 1, -1, 1, -1, 1 },
{ 1, 1, 1, 1, -1, 1, -1, 1, -1, 1 },
{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
{ 1, 1, 1, 1, -1, 1, -1, -1, -1, -1 },
{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
{ 1, 1, 1, 1, -1, -1, -1, -1, -1, 1 },
{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
{ 1, 1, 1, 1, -1, -1, -1, -1, -1, -1 } };
char x1[] = { '+', '-', '*', '/', '(', ')', '[', ']', '{ ', '}' };// 栈顶元素
char x2[] = { '+', '-', '*', '/', '(', ')', '[', ']', '{ ', '}' };// 算术表达式中的元素
int k = 0, m, n = 0;
for (m = 0; m < ; m++) // 查找2个进行比较的运算符在表中的位置,并返回比较结果
{
for (n = 0; n < ; n++)
{
if (x1[m] == a && x2[n] == b)
{
k = 1;
break; // 找到比较结果后,跳出循环
}
}
if (k == 1)
break;
}
return s[m][n];// 返回比较结果
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == jButton1)
{
show += "1";
text.setText(show);
}
if (e.getSource() == jButton2)
{
show += "2";
text.setText(show);
}
if (e.getSource() == jButton3)
{
show += "3";
text.setText(show);
}
if (e.getSource() == jButton4)
{
show += "4";
text.setText(show);
}
if (e.getSource() == jButton5)
{
show += "5";
text.setText(show);
}
if (e.getSource() == jButton6)
{
show += "6";
text.setText(show);
}
if (e.getSource() == jButton7)
{
show += "7";
text.setText(show);
}
if (e.getSource() == jButton8)
{
show += "8";
text.setText(show);
}
if (e.getSource() == jButton9)
{
show += "9";
text.setText(show);
}
if (e.getSource() == jButton)
{
show += "0";
text.setText(show);
}
if (e.getSource() == jButton)
{
show += "+";
text.setText(show);
}
if (e.getSource() == jButton)
{
show += "-";
text.setText(show);
}
if (e.getSource() == jButton)
{
show += "*";
text.setText(show);
}
if (e.getSource() == jButton)
{
show += "/";
text.setText(show);
}
if (e.getSource() == jButton)
{
show += "(";
text.setText(show);
}
if (e.getSource() == jButton)
{
show += ")";
text.setText(show);
}
if (e.getSource() == jButton)
{
show += "[";
text.setText(show);
}
if (e.getSource() == jButton)
{
show += "]";
text.setText(show);
}
if (e.getSource() == jButton)
{
show += "{ ";
text.setText(show);
}
if (e.getSource() == jButton)
{
show += "}";
text.setText(show);
}
if (e.getSource() == jButton)
{
show = "";
text.setText("");
text1.setText("");
}
if (e.getSource() == jButton)
{
show += "=";
text.setText(show);
char str1[] = new char[];
char str2[] = new char[];
float result = 0;
str1 = show.toCharArray();
str2 = TranSmit(str1);
result = Count(str2);
text1.setText((new String(str2)).trim());
text.setText("" + result);
show = "";
}
}
private void initComponents()
{
text.setBounds(, , , );
text1.setBounds(, , , );
jButton1.setBounds(, , , );
jButton2.setBounds(, , , );
jButton3.setBounds(, , , );
jButton4.setBounds(, , , );
jButton5.setBounds(, , , );
jButton6.setBounds(, , , );
jButton7.setBounds(, , , );
jButton8.setBounds(, , , );
jButton9.setBounds(, , , );
jButton.setBounds(, , , );
jButton.setBounds(, , , );
jButton.setBounds(, , , );
jButton.setBounds(, , , );
jButton.setBounds(, , , );
jButton.setBounds(, , , );
jButton.setBounds(, , , );
jButton.setBounds(, , , );
jButton.setBounds(, , , );
jButton.setBounds(, , , );
jButton.setBounds(, , , );
jButton.setBounds(, , , );
jButton.setBounds(, , , );
jButton1.setText("1");
jButton2.setText("2");
jButton3.setText("3");
jButton4.setText("4");
jButton5.setText("5");
jButton6.setText("6");
jButton7.setText("7");
jButton8.setText("8");
jButton9.setText("9");
jButton.setText("0");
jButton.setText("+");
jButton.setText("-");
jButton.setText("*");
jButton.setText("/");
jButton.setText("(");
jButton.setText(")");
jButton.setText("[");
jButton.setText("]");
jButton.setText("{ ");
jButton.setText("}");
jButton.setText("CE");
jButton.setText("=");
jButton1.addActionListener(this);
jButton2.addActionListener(this);
jButton3.addActionListener(this);
jButton4.addActionListener(this);
jButton5.addActionListener(this);
jButton6.addActionListener(this);
jButton7.addActionListener(this);
jButton8.addActionListener(this);
jButton9.addActionListener(this);
jButton.addActionListener(this);
jButton.addActionListener(this);
jButton.addActionListener(this);
jButton.addActionListener(this);
jButton.addActionListener(this);
jButton.addActionListener(this);
jButton.addActionListener(this);
jButton.addActionListener(this);
jButton.addActionListener(this);
jButton.addActionListener(this);
jButton.addActionListener(this);
jButton.addActionListener(this);
jButton.addActionListener(this);
add(text);
add(text1);
add(jButton1);
add(jButton2);
add(jButton3);
add(jButton4);
add(jButton5);
add(jButton6);
add(jButton7);
add(jButton8);
add(jButton9);
add(jButton);
add(jButton);
add(jButton);
add(jButton);
add(jButton);
add(jButton);
add(jButton);
add(jButton);
add(jButton);
add(jButton);
add(jButton);
add(jButton);
add(jButton);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(null);
setBounds(, , , );
setVisible(true);
}
public static void main(String args[])
{
new jisuanqi();
}
}
dpvs源码
cps网站源码_cpp典型网站
hadoop hdfs 源码
e模块 源码_ecm模块软件
easydl源码
android 源码大小