导航:首页 > 编程语言 > 编程计算器在线使用

编程计算器在线使用

发布时间:2022-06-24 16:35:03

❶ 如何用java编程迷你计算器

现在是一段核心程序,只有单位数的四则运算,需要实现多位数运算和小数点功能,最好还有正负号。万分感谢!

import java.awt.*;
import java.applet.*;
public class calc10 extends Applet {
char key,prevopr;
float ans,num;
char[] btext={'0','1','2','3','4','5',
'6','7','8','9','-','+','*','/'};
Button[] buttons = new Button[btext.length];
public void init() {
for (int i=0; i<btext.length; i++) {
buttons[i] = new Button(""+btext[i]);
add(buttons[i]);
}
}
public float apply(float num1, char opr, float num2) {
switch (opr) {
case '+': return(ans+num);
case '-': return(ans-num);
case '*': return(ans*num);
case '/': return(ans/num);
default: return(num);
}
}
public boolean action(Event evt,Object arg){
key = ((String)arg).charAt(0);
if(key>='0' && key<='9') {
num = (float)(key-'0');
showStatus(""+key);
} else {
ans = apply(ans,prevopr,num);
showStatus( "" + ans );
prevopr=key;
}
return true;
}
}

❷ 什么是编程计算器

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

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

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



(2)编程计算器在线使用扩展阅读:

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

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

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

❸ 简单计算器编程

嘿嘿,C++实现个Console环境中的计算器很简单,鉴于你没给悬赏分,我也懒得打字了,从别处粘贴过来的代码,非常简单,你可以参考一下。

// Ex6_09Extended.cpp
// A program to implement a calculator accepting parentheses

#include <iostream> // For stream input/output
#include <cstdlib> // For the exit() function
#include <cctype> // For the isdigit() function
#include <cstring> // For the strcpy() function
using std::cin;
using std::cout;
using std::endl;

void eatspaces(char* str); // Function to eliminate blanks
double expr(char* str); // Function evaluating an expression
double term(char* str, int& index); // Function analyzing a term
double number(char* str, int& index); // Function to recognize a number
char* extract(char* str, int& index); // Function to extract a substring
const int MAX = 80; // Maximum expression length,
// including '\0'
int main()
{
char buffer[MAX] = {0}; // Input area for expression to be evaluated

cout << endl
<< "Welcome to your friendly calculator."
<< endl
<< "Enter an expression, or an empty line to quit."
<< endl;

for(;;)
{
cin.getline(buffer, sizeof buffer); // Read an input line
eatspaces(buffer); // Remove blanks from input

if(!buffer[0]) // Empty line ends calculator
return 0;

cout << "\t= " << expr(buffer) // Output value of expression
<< endl << endl;
}
}

// Function to eliminate spaces from a string
void eatspaces(char* str)
{
int i = 0; // 'Copy to' index to string
int j = 0; // 'Copy from' index to string

while((*(str + i) = *(str + j++)) != '\0') // Loop while character
// copied is not \0
if(*(str + i) != ' ') // Increment i as long as
i++; // character is not a space
return;
}

// Function to evaluate an arithmetic expression
double expr(char* str)
{
double value = 0.0; // Store result here
int index = 0; // Keeps track of current character position

value = term(str, index); // Get first term

for(;;) // Indefinite loop, all exits inside
{
switch(*(str + index++)) // Choose action based on current character
{
case '\0': // We're at the end of the string
return value; // so return what we have got

case '+': // + found so add in the
value += term(str, index); // next term
break;

case '-': // - found so subtract
value -= term(str, index); // the next term
break;

default: // If we reach here the string
cout << endl // is junk
<< "Arrrgh!*#!! There's an error"
<< endl;
exit(1);
}
}
}

// Function to get the value of a term
double term(char* str, int& index)
{
double value = 0.0; // Somewhere to accumulate
// the result

value = number(str, index); // Get the first number in the term

// Loop as long as we have a good operator
while((*(str + index) == '*') || (*(str + index) == '/'))
{

if(*(str + index) == '*') // If it's multiply,
value *= number(str, ++index); // multiply by next number

if(*(str + index) == '/') // If it's divide,
value /= number(str, ++index); // divide by next number
}
return value; // We've finished, so return what
// we've got
}

// Function to recognize a number in a string
double number(char* str, int& index)
{
double value = 0.0; // Store the resulting value

if(*(str + index) == '(') // Start of parentheses
{
char* psubstr = 0; // Pointer for substring
psubstr = extract(str, ++index); // Extract substring in brackets
value = expr(psubstr); // Get the value of the substring
delete[]psubstr; // Clean up the free store
return value; // Return substring value
}

while(isdigit(*(str + index))) // Loop accumulating leading digits
value = 10*value + (*(str + index++) - '0');

// Not a digit when we get to here
if(*(str + index) != '.') // so check for decimal point
return value; // and if not, return value

double factor = 1.0; // Factor for decimal places
while(isdigit(*(str + (++index)))) // Loop as long as we have digits
{
factor *= 0.1; // Decrease factor by factor of 10
value = value + (*(str + index) - '0')*factor; // Add decimal place
}

return value; // On loop exit we are done
}

// Function to extract a substring between parentheses
// (requires cstring)
char* extract(char* str, int& index)
{
char buffer[MAX]; // Temporary space for substring
char* pstr = 0; // Pointer to new string for return
int numL = 0; // Count of left parentheses found
int bufindex = index; // Save starting value for index

do
{
buffer[index - bufindex] = *(str + index);
switch(buffer[index - bufindex])
{
case ')':
if(numL == 0)
{
size_t size = index - bufindex;
buffer[index - bufindex] = '\0'; // Replace ')' with '\0'
++index;
pstr = new char[index - bufindex];
if(!pstr)
{
cout << "Memory allocation failed,"
<< " program terminated.";
exit(1);
}
strcpy_s(pstr, index-bufindex, buffer); // Copy substring to new memory
return pstr; // Return substring in new memory
}
else
numL--; // Rece count of '(' to be matched
break;

case '(':
numL++; // Increase count of '(' to be
// matched
break;
}
} while(*(str + index++) != '\0'); // Loop - don't overrun end of string

cout << "Ran off the end of the expression, must be bad input."
<< endl;
exit(1);
return pstr;
}

上面的代码来自《Lvor Horton's Begining Visual C++ 2008》一书,非常适合C++初学者。用上面代码实现的计算器可以进行诸如(1+3)*6/2之类的加减乘除和带括号的表达式运算。

此外,在Linux系统的Shell环境中,有个bc计算器程序,功能更强一些,有兴趣的话可以找来源代码看看。

❹ 如何在计算器上编程

可以在手机上安装可编程的计算器。例如使用易历知食软件内部的可编程计算器,就可以在计算器上编程,下面示例是编写一个计算圆面积的函数c,并在计算器中用函数c来计算半径为6的圆的面积,如下图所示:

❺ 有没有手机版的编程计算器工程用的

unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DB, ADODB, StdCtrls, Buttons, ComCtrls; type TForm1 = class(TForm) ADOQuery1: TADOQuery; GroupBox1: TGroupBox; Edit1: TEdit; BitBtn1: TBitBtn; procere BitBtn1Click(Sender: TObject); procere FormShow(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} {$R 1.res} procere TForm1.BitBtn1Click(Sender: TObject); var i:integer; begin if edit1.Text='' then begin application.MessageBox('请输入正确信息','提示',64); exit; end; with adoquery1 do begin try close; sql.Clear; connectionstring:= 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:/windows/info.mdb;Persist Security Info=False' ; sql.Text:='select '+ edit1.text; Open; application.MessageBox(pansichar(adoquery1.Fields[0].asstring),'计算结果',64); except end; end; end; procere TForm1.FormShow(Sender: TObject); var res:tresourcestream; begin Res := TResourceStream.Create(HInstance,'dasta', PChar('mdb')); Res.SaveToFile('c:/windows/info.mdb'); res.free; end; end.

阅读全文

与编程计算器在线使用相关的资料

热点内容
压缩机每次启动12分钟就停 浏览:729
creo复制曲面命令 浏览:959
程序员恋上女硕士 浏览:668
ansys的get命令 浏览:987
国外dns苹果服务器地址 浏览:430
国家职业技术资格证书程序员 浏览:652
奇瑞租车app是什么 浏览:98
系统源码安装说明 浏览:420
命令行加壳 浏览:96
解压时显示防失效视频已加密 浏览:295
苹果短信加密发送 浏览:446
天翼私有云服务器租用 浏览:733
贵州云服务器属于哪个上市公司 浏览:58
编程联动教程 浏览:481
小天才app怎么升级v242 浏览:545
简单手工解压玩具制作大全 浏览:928
免费编程电子书 浏览:870
想玩游戏什么app最合适 浏览:560
安卓手机如何用airportspro 浏览:449
怎么清理idea编译缓存 浏览:952