您好,欢迎访问三七文档
当前位置:首页 > 金融/证券 > 金融资料 > 银行ATM自动取款机模拟系统实验报告
西安科技大学《VC++语言程序设计》实验报告题目__科学计算器的实现______院、系(部)计算机科学与技术学院专业及班级软件工程1102班姓名赵文杰日期2012/11/921.题目:科学计算器2.功能需求:这是计算器,在满足用户需求方面应有以下功能:1)进行简单的加、减、乘、除;2)进行函数运算如sin、cos、tan函数;3)可进行进制转换、及弧度运算;3.总体设计4.详细设计以下是详细的分部:1基于MFC创建一个基本对话框Calculator2实现基本运算的代码:voidCCalculatorDlg::OnNumberKey(UINTnID){CStringn;switch(nID){caseIDC_NUMBER1:n=1;break;caseIDC_NUMBER2:n=2;break;caseIDC_NUMBER3:n=3;break;caseIDC_NUMBER4:n=4;break;caseIDC_NUMBER5:n=5;break;caseIDC_NUMBER6:n=6;break;caseIDC_NUMBER7:n=7;break;caseIDC_NUMBER8:n=8;break;caseIDC_NUMBER9:n=9;break;caseIDC_NUMBER0:n=0;break;计算器基本运算函数运算进制转化几弧度3caseIDC_NUMBER_Point:n=.;if(Point==TRUE){m_Point.ShowWindow(SW_HIDE);Point=FALSE;}break;}if(NumberState==1){m_Cnumber=m_Cnumber+n;number1=atof(m_Cnumber);UpdateData(FALSE);}else{m_Cnumber=m_Cnumber+n;number2=atof(m_Cnumber);UpdateData(FALSE);}if(Zero=FALSE){Zero=TRUE;m_Zero.ShowWindow(SW_SHOW);}}voidCCalculatorDlg::OnOperationKey(UINTnID){m_number=atof(m_Cnumber);switch(nID){caseIDC_NUMBER_PlusMinus:m_number=m_number;if(NumberState==1)number1=m_number;elsenumber2=m_number;m_Cnumber.Format(%g,m_number);UpdateData(FALSE);break;caseIDC_NUMBER_BackSpace:intn;n=m_Cnumber.GetLength();4m_Cnumber=m_Cnumber.Left(n-1);UpdateData(FALSE);break;caseIDC_NUMBER_Divide:cal();if(Zero==TRUE){m_Zero.ShowWindow(SW_HIDE);Zero=FALSE;}OperationState=1;m_number=0;m_Cnumber=;NumberState=2;break;caseIDC_NUMBER_Multiply:cal();OperationState=2;m_number=0;m_Cnumber=;NumberState=2;break;caseIDC_NUMBER_Add:cal();OperationState=3;m_number=0;m_Cnumber=;NumberState=2;break;caseIDC_NUMBER_Subtract:cal();OperationState=4;m_number=0;m_Cnumber=;NumberState=2;break;caseIDC_NUMBER_Clear:number1=number2=m_number=0;m_Cnumber.Format(%g,m_number);UpdateData(FALSE);m_Cnumber=;NumberState=1;break;caseIDC_NUMBER_Sqrt:number1=m_number=sqrt(number1);m_Cnumber.Format(%g,m_number);UpdateData(FALSE);5break;caseIDC_NUMBER_Sin:number1=m_number=sin(number1);m_Cnumber.Format(%g,m_number);UpdateData(FALSE);break;caseIDC_NUMBER_Cos:number1=m_number=cos(number1);m_Cnumber.Format(%g,m_number);UpdateData(FALSE);break;caseIDC_NUMBER_Tan:number1=m_number=tan(number1);m_Cnumber.Format(%g,m_number);UpdateData(FALSE);break;caseIDC_NUMBER_Log:number1=m_number=log(number1);m_Cnumber.Format(%g,m_number);UpdateData(FALSE);break;caseIDC_NUMBER_Log10:number1=m_number=log10(number1);m_Cnumber.Format(%g,m_number);UpdateData(FALSE);break;caseIDC_NUMBER_Exp:number1=m_number=exp(number1);m_Cnumber.Format(%g,m_number);UpdateData(FALSE);break;caseIDC_NUMBER_Derivative:number1=m_number=(double)1/number1;m_Cnumber.Format(%g,m_number);UpdateData(FALSE);break;caseIDC_NUMBER_Equal:cal();break;}if(Point==FALSE){Point=TRUE;m_Point.ShowWindow(SW_SHOW);6}}3函数的实现代码:voidCCalculatorDlg::OnOperationKey(UINTnID){m_number=atof(m_Cnumber);switch(nID){caseIDC_NUMBER_PlusMinus:m_number=m_number;if(NumberState==1)number1=m_number;elsenumber2=m_number;m_Cnumber.Format(%g,m_number);UpdateData(FALSE);break;caseIDC_NUMBER_BackSpace:intn;n=m_Cnumber.GetLength();m_Cnumber=m_Cnumber.Left(n-1);UpdateData(FALSE);break;caseIDC_NUMBER_Divide:cal();if(Zero==TRUE){m_Zero.ShowWindow(SW_HIDE);Zero=FALSE;}OperationState=1;m_number=0;m_Cnumber=;NumberState=2;break;caseIDC_NUMBER_Multiply:cal();OperationState=2;m_number=0;m_Cnumber=;NumberState=2;break;caseIDC_NUMBER_Add:cal();OperationState=3;m_number=0;m_Cnumber=;7NumberState=2;break;caseIDC_NUMBER_Subtract:cal();OperationState=4;m_number=0;m_Cnumber=;NumberState=2;break;caseIDC_NUMBER_Clear:number1=number2=m_number=0;m_Cnumber.Format(%g,m_number);UpdateData(FALSE);m_Cnumber=;NumberState=1;break;caseIDC_NUMBER_Sqrt:number1=m_number=sqrt(number1);m_Cnumber.Format(%g,m_number);UpdateData(FALSE);break;caseIDC_NUMBER_Sin:number1=m_number=sin(number1);m_Cnumber.Format(%g,m_number);UpdateData(FALSE);break;caseIDC_NUMBER_Cos:number1=m_number=cos(number1);m_Cnumber.Format(%g,m_number);UpdateData(FALSE);break;caseIDC_NUMBER_Tan:number1=m_number=tan(number1);m_Cnumber.Format(%g,m_number);UpdateData(FALSE);break;caseIDC_NUMBER_Log:number1=m_number=log(number1);m_Cnumber.Format(%g,m_number);UpdateData(FALSE);break;caseIDC_NUMBER_Log10:number1=m_number=log10(number1);m_Cnumber.Format(%g,m_number);UpdateData(FALSE);8break;caseIDC_NUMBER_Exp:number1=m_number=exp(number1);m_Cnumber.Format(%g,m_number);UpdateData(FALSE);break;caseIDC_NUMBER_Derivative:number1=m_number=(double)1/number1;m_Cnumber.Format(%g,m_number);UpdateData(FALSE);break;caseIDC_NUMBER_Equal:cal();break;}if(Point==FALSE){Point=TRUE;m_Point.ShowWindow(SW_SHOW);}}CCalculatorDlg::cal(){m_number=atof(m_Cnumber);switch(OperationState){case1:m_number=(double)number1/number2;NumberState=1;m_Cnumber.Format(%g,m_number);UpdateData(FALSE);break;case2:m_number=(double)number1*number2;NumberState=1;m_Cnumber.Format(%g,m_number);UpdateData(FALSE);break;case3:m_number=(double)number1+number2;NumberState=1;m_Cnumber.Format(%g,m_number);UpdateData(FALSE);9break;case4:m_number=(double)number1-number2;NumberState=1;m_Cnumber.Format(%g,m_number);UpdateData(FALSE);bre
本文标题:银行ATM自动取款机模拟系统实验报告
链接地址:https://www.777doc.com/doc-5690834 .html