VC++课程设计 联系客服

发布时间 : 星期二 文章VC++课程设计更新完毕开始阅读

科学计算器设计

m_xx=m_xx+\ str='f';

UpdateData(false);

// TODO: Add your control notification handler code here }

void CMyDlg::Onkf() { s2=\ s1=m_xx;

m_xx=m_xx+\ str='k';

UpdateData(false); // TODO: Add your control notification handler code here }

void CMyDlg::Onln() {s2=\ s1=m_xx; m_xx=\ str='l';

UpdateData(false);

// TODO: Add your control notification handler code here }

void CMyDlg::Onlog() { s2=\ s1=m_xx;

m_xx=\ str='g';

UpdateData(false);

// TODO: Add your control notification handler code here }

void CMyDlg::Onpf()

- - 16 - -

科学计算器设计

{s2=\ s1=m_xx; m_xx=m_xx+\ str='p';

UpdateData(false);

// TODO: Add your control notification handler code here }

void CMyDlg::Onsin() {s2=\ s1=m_xx;

m_xx=\ str='s';

UpdateData(false);

// TODO: Add your control notification handler code here }

void CMyDlg::Onsub() { s2=\ s1=m_xx; m_xx=m_xx+'-'; str='-';

UpdateData(false);

// TODO: Add your control notification handler code here }

void CMyDlg::Onsze() { s2=\ int n,i,t; double Y,p=0.0;

Y=strtod( m_xx,NULL); t=(int)(Y); if(t!=1)

for(i=1;t>1;i++)

- - 17 - -

科学计算器设计

{

n=t%2; t=t/2;

p+=n*pow(10,(i-1)); }

p+=1*pow(10,(i-1)); m_xx.Format(\

UpdateData(false);// TODO: Add your control notification handler code here }

void CMyDlg::Ontan() {s2=\ s1=m_xx;

m_xx=\ str='t';

UpdateData(false);

// TODO: Add your control notification handler code here }

void CMyDlg::Onxy() { s2=\ s1=m_xx; m_xx=m_xx+\ str='^';

UpdateData(false); // TODO: Add your control notification handler code here }

void CMyDlg::Onds() {s2=s2+\ m_xx=m_xx+\

- - 18 - -

科学计算器设计

UpdateData(false);

// TODO: Add your control notification handler code here }

(2)函数功能说明

整个计算器除了基本的加、减、乘、除运算外,另外还有8个功能,实现八大运算:三角函数运算功能、对数函数运算功能、指数函数运算功能、乘方运算功能、平方运算功能、根式运算功能、进制转换功能、归零功能。各个运算功能的详细设计说明分别如下: 1、基本运算功能

主要实现数据的加、减、乘、除运算,提供简单的科学计算! 2、三角函数运算功能

用来执行三角函数的运算,包括正弦函数(sin)、余弦函数(cos)、正切函数(tan)和余切函数(cot)。 3、对数函数运算功能

用来执行对数函数的运算,包括以e为底ln函数和以10为底的lg函数。 4、指数函数运算功能 用来执行指数函数的运算。 5、乘方运算功能

用来执行乘方的运算,进行数值的成倍计算。 6、平方运算功能

用来执行平方运算,说到底它也属于乘方运算的范畴。 7、根式运算功能 用来执行根式的运算。 8、进制转换运算功能

主要实现数值间的转换,包括二进制转十进制、十进制转二进制和八进制转二进制的运算。

二进制转十进制N-S流程图:

int len; double sum=0.0,num; len=strlen(m_xs); int i=0;i