欢迎来到天天文库
浏览记录
ID:61499127
大小:180.00 KB
页数:10页
时间:2021-02-07
《VC语言综合实训.doc》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、VC++程序设计综合实训开发报告设计题目计算器专业班级计科1001班日期2012年12月1日开发小组成员组长:袁军组员:王超雷洁林良杰王浪高雨欣袁军一、题目要求设计计算器二、题目分析设计一个计算器,要能实现计算器的基本功能:+-*/.画出计算器的界面,显示界面,以及各个按钮,并且实现每个按钮的功能。三、核心程序代码CMyDlg::CMyDlg(CWnd*pParent/*=NULL*/):CDialog(CMyDlg::IDD,pParent){//{{AFX_DATA_INIT(CMyDlg)
2、//}}AFX_DATA_INIT//NotethatLoadIcondoesnotrequireasubsequentDestroyIconinWin32m_hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);m_lNum="";m_rNum="";m_bIsLNum=true;m_ilNumber=0;m_irNumber=0;m_operand='';m_bIslFirstTime=true;m_bIsrFirstTime=true;}voidCMyDlg
3、::OnButton1(){//TODO:Addyourcontrolnotificationhandlercodehereif(m_bIsLNum){m_lNum+="1";m_result.SetWindowText(m_lNum);}else{m_rNum+="1";m_result.SetWindowText(m_rNum);}}voidCMyDlg::OnButtonAdd(){//TODO:Addyourcontrolnotificationhandlercodeherem_resu
4、lt.SetWindowText(_T("+"));m_bIsLNum=false;m_operand='+';}voidCMyDlg::OnButtonDiv(){//TODO:Addyourcontrolnotificationhandlercodeherem_result.SetWindowText(_T("/"));m_bIsLNum=false;m_operand='/';}voidCMyDlg::OnButtonEqu(){//TODO:Addyourcontrolnotificat
5、ionhandlercodeheredoubleresult=0;CStringstrResult="";switch(m_operand){case'+':m_ilNumber=atof(m_lNum);m_irNumber=atof(m_rNum);result=m_ilNumber+m_irNumber;strResult.Format("%lf",result);break;case'-':m_ilNumber=atof(m_lNum);m_irNumber=atof(m_rNum);r
6、esult=m_ilNumber-m_irNumber;strResult.Format("%lf",result);break;case'*':m_ilNumber=atof(m_lNum);m_irNumber=atof(m_rNum);result=m_ilNumber*m_irNumber;strResult.Format("%lf",result);break;case'/':m_ilNumber=atof(m_lNum);m_irNumber=atof(m_rNum);result=
7、m_ilNumber/m_irNumber;strResult.Format("%lf",result);break;}m_result.SetWindowText(strResult);m_bIsLNum=true;m_rNum="";m_lNum="";m_ilNumber=0;m_irNumber=0;}voidCMyDlg::OnButtonMul(){//TODO:Addyourcontrolnotificationhandlercodeherem_result.SetWindowTe
8、xt(_T("*"));m_bIsLNum=false;m_operand='*';}voidCMyDlg::OnButtonSub(){//TODO:Addyourcontrolnotificationhandlercodeherem_result.SetWindowText(_T("—"));m_bIsLNum=false;m_operand='-';}voidCMyDlg::OnButton2(){//TODO:Addyourcontrolnotificationhandlercodehe
此文档下载收益归作者所有