版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
C++课程设计报告( C++课程设计报告( 2011)C++课程设计报告( C++课程设计报告( 2011)C++课程设计报告(20—20年度第学期)计算器的设计与实现专业 计算机科学与技术 学生姓名 班级 学号 指导教师 完成日期目录TOC\o"1-5"\h\z\o"CurrentDocument"1概述 31.1课程设计目的 31.2课程设计内容 3\o"CurrentDocument"2系统需求分析 32.1系统目标 32.2主体功能 32.3开发环境 3\o"CurrentDocument"3系统概要设计 4\o"CurrentDocument"3.1系统功能划分 43.2系统流程图 5\o"CurrentDocument"4系统详细设计 54.1设计步骤 54.2界面设计 74.2实现高级按钮控件类 10\o"CurrentDocument"5测试 115.1测试方案 115.2测试结果 11\o"CurrentDocument"6小结 12\o"CurrentDocument"参考文献 14附录 15\o"CurrentDocument"附录1源程序清单 15计算器的设计与实现计算器的设计与实现C++C++课程设计报告( 2011)sin30、(如图5-2所示)。图5-2求sin30测试结果图(一)05 金度数 c弧度a科学塑 Q标准型 ■01121+C呵1In3 | 4-1-sqrt小1环|6|1j-8*l/xcos|g1v-1■/I 1ly,氐1旦]图5・3求sin30测试结果图(二)6小结通过一个多星期的折腾,总算把课程设计给完成了,这是一个坚苦而又漫长的过程。看着劳动成果,很欣慰!刚开始,可以说是完全没有头绪,于是上网查,找到了些与我题目相似的源代码,然后对之进行修改,测试,最后得到我这次课程设计所需要的代码 ・通过计算器的设计这一课题的设计和实现,我对简单的 C语言编程有了进一步的认识,对MicrosoftVisualC++6.0 这个程序的操作更加熟练了一些。回顾此次的课程设计,我学到了很多东西不仅巩固了书本的知识并且与实践相结合提高具体操作能力,在设计的过程中发现自己的不足,有些知识掌握的不够牢靠,通过这次的课程设计之后我把前面所学的知识又重新温故了一遍。同时,在老师和同学身上我学到了很多非常实用的知识,在此对给过我帮助的同学和老师表示由衷的感谢!参考文献[1]谭浩强・C程序设计(第三版)[M]・北京:清华大学出版社,2005.⑵谭浩强・C程序设计题解与上机指导(第三版)[M]・北京:清华大学出版社,2005.[3]甄炜.C++语言和面向对象程序设计教程[M]・北京:机械工业出版社,2005.附录1源程序清单//CalculatorDlg.cpp:implementationtile#include"stdaix.h"#include"Calculator.h"#include"CalculatorDlg.h"#include"math.h"#iftlef_DEBUG#detinenewDEBUG_NEW#undefTHIS_FILEstaticcharTHIS_FILE[]=__FILE__;#endiflllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll//CAboutDlgdialogusedforAppAboutclassCAboutDlg:publicCDialog{public:CAboutDlg();//DialogData//{{AFX_DATA(CAboutDlg)enum{IDD=IDD_ABOUTBOX};//})AFX_DATA//ClassWizardgeneratedvirtualfunctionoverrides//{{AFX_VIRTUAL(CAboutDlg)//DDX/DDVsupportprotected://DDX/DDVsupportvirtualvoidDoDataExchange(CDataExchange*pDX);//}}AFX_VIRTUAL//Implementationprotected://{{AFX_MSG(CAboutDlg)//}}AFX_MSGDECLARE_MESSAGE_MAP()};CAboutDlg::CAboutDlg():CDialog(CAboutDlg::IDD){//{{AFX_DATA_INIT(CAboutDlg)//}}AFX_DATA_INIT}voidCAboutDlg::DoDataExchange(CDataExchange*pDX){CDialog::DoDataExchange(pDX);//{{AFX_DATA_MAP(CAboutDlg)//}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(CAboutDlg,CDialog)//{{AFX_MSG_MAP(CAboutDlg)//Nomessagehandlers//}}AFX_MSG_MAPEND_MESSAGE_MAP()lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll//CCalculatorDlgdialogCCalculatorDlg::CCalculatorDlg(CWnd*pParent/*=NULL*/):CDialog(CCalculatorDlg::IDD,pParent){//{{AFX_DATA_INIT(CCalculatorDlg)m_result=_T(,H,);m_isDegree=-1;m_sentific=・1;//}}AFX_DATA_INrr//NotethatLoadicondoesnotrequireasubsequentDestroyIconinWin32m_hlcon=AlxGetApp()->LoadIcon(IDR_MAINFRAME);m_hAccel=LoadAccelerators(AixGetinstaneeHandle(),MAKEINTRESOURCE(IDD));DtoR=l;m_coff=0.1;m_bCoff=0;m_errorState=ErrNone;m_bOperandAvail=FALSE;m_operator=OpNone;}voidCCalculatorDlg::DoDataExchange(CDataExchange*pDX){CDialog::DoDataExchange(pDX);//{{AFX_DATA_MAP(CCalculatorDlg)DDX_Text(pDX,IDC_DISPLAY,m_result);DDX_Radio(pDX,IDC_DEGREE,m_isDegree);DDX_Radio(pDX,IDC_SENTIFIC,m_sentitic);//}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(CCalculatorDlg,CDialog)//{{AFX_MSG_MAP(CCalculatorDlg)ON_WM_SYSCOMMANDOON_WM_PAINT()ON_WM_QUERYDRAGICON()ON_COMMAND_RANGE(IDC_0,IDC_9,OnOperandlnput)ON_BN_CLICKED(IDC_ADD,OnAdd)ON_BN_CLICKED(IDC_MINUS,OnMinus)ON_BN_CLICKED(IDC_DIVID,OnDivid)ON_BN_CLICKED(IDC_MULTIPLY,OnMultiply)ON_BN_CLICKED(IDC_EQUAL,OnEqual)ON_BN_CLICKED(IDC_SQRT,OnSqrt)ON_BN_CLICKED(IDC_SIGN,OnSign)ON_BN_CLICKED(IDC_RECIPROCAL,OnReciprocal)ON_BN_CLICKED(IDC_POINT,OnPoint)ON_BN_CLICKED(IDC_CLEAR,OnClear)ON_BN_CLICKED(IDC_LOG,OnLog)ON_BN_CLICKED(IDC_LN,OnLn)ON_BN_CLICKED(IDC_FACTORIAL,OnFactorial)ON_BN_CLICKED(IDC_EXP,OnExp)ON_BN_CLICKED(IDC_SENTIFIC,OnSentific)ON_BN_CLICKED(IDC_SIN,OnSin)ON_BN_CLICKED(IDC_SQUAR,OnSquar)ON_BN_CLICKED(IDC_TAN,OnTan)ON_BN_CLICKED(IDC_STANDARD,OnStandard)ON_BN_CLICKED(IDC_DEGREE,OnDegree)ON_BN_CLICKED(IDC_RAD,OnRad)ON_BN_CLICKED(IDC_COS,OnCos)//}}AFX_MSG_MAPEND_MESSAGE_MAP()IICCalculatorDlgmessagehandlersBOOLCCalculatorDlg::OnInitDialog(){CDialog::OnInitDialog();//Add”About...”menuitemtosystemmenu.//IDM_ABOUTBOXmustbeinthesystemcommandrange.ASSERT((IDM_ABOUTBOX&OxFFFO)==EDM.ABOUTBOX);ASSERT(IDM_ABOUTBOX<OxFOOO);CMenu*pSysMenu=GetSystemMenu(FALSE);if(pSysMenu!=NULL){CStringstrAboutMenu;strAboutMenu.Loadstring(IDS_ABOUTBOX);if(!strAboutMenu.IsEmptyO){pSysMenu->AppendMenu(MF_SEPARATOR);pSysMenu・>AppendMenu(MF_STRING,IDM_ABOUTBOX,strAboutMenu);}}//Settheiconforthisdialog.Theframeworkdoesthisautomatically//whentheapplication'smainwindowisnotadialogSetlcon(m_hlcon,TRUE); //SetbigiconSetlcon(m_hlcon,FALSE); //Setsmallicon//TODO:AddextrainitializationhereGetWindowRect(rcSentitle);CWnd*m_pMark=GetDlgItem(IDC_DISPLAY);ASSERT(m_pMark);CRectrect;m_pMark->GetWindowRect(rect);rcStandard=rcSentific;rcStandard.right=rect.right+5;m_bIsExpand=0;m_sentific=l;OnStandard();m_result=n0.n;m_isDegree=l;UpdateData(FALSE);returnTRUE;//returnTRUEunlessyousetthefocustoacontrol}voidCCalculatorDlg::OnSysCommand(UINTnID,LPARAMIParam){if((nID&OxFFFO)==EDM_ABOUTBOX){CAboutDlgdigAbout;dlgAbout.DoModal();}else{CDialog::OnSysCommand(nID,IParam);}}//Ifyouaddaminimizebuttontoyourdialog,youwillneedthecodebelow//todrawtheicon.ForMFCapplicationsusingthedocument/viewmodel,//thisisautomaticallydoneforyoubytheframework.voidCCalculatorDlg::OnPaint(){if(Islconic()){CPaintDCdc(this);//devicecontextforpaintingSendMessage(WM_ICONERASEBKGND,(WPARAM)dc.GetSafeHdc(),0);//Centericoninclientrectangleintcxlcon=GetsystemMetries(SM_CXICON);intcylcon=GetsystemMetries(SM_CYICON);CRectrect;GetClientRect(&rect);intx=(rect.Width()・cxlcon+1)/2;inty=(rect.Height()・cylcon+1)/2;//Drawtheicondc.DrawIcon(x,y,m_hlcon);}else{CDialog::OnPaint();}}//Thesystemcallsthistoobtainthecursortodisplaywhiletheuserdrags//theminimizedwindow.HCURSORCCalculatorDlg::OnQueryDragIcon(){return(HCURSOR)m_hlcon;}voidCCalculatorDlg::OnOperandInput(UINTnID){ASSERT(nID>=IDC_0&&nID<=IDC_9);if(m_errorState!=ErrNone)return;if(m_func!=FuncNone){m_func=FuncNone;Calculate();}if(!m_bOperandAvail)m_operand=0;if(!m_bCoH)m_operand=m_operand*10+(nID-IDC_0);else{m_operand=m_operand+(nID-IDC_0)*m_colT;m_cofP=0.1;}m_bOperandAvail=TRUE;UpdateDisplayO;}voidCCalculatorDlg::Calculate(){if(m_errorState!=ErrNone)return;if(m_bOperandAvail)if(m_operator==OpNone)m_accum=m_operand;elseif(m_operator==OpMultiply)m_accum*=m_operand;elseif(m_operator==OpDivide){if(m_operand==0)m_errorState=ErrDivideByZero;elsem_accum/=m_operand;}elseif(m_operator==OpAdd)m_accum+=m_operand;elseif(m_operator==OpSubtract)m_accum-=m_operand;}m_bOperandAvail=FALSE;m_bCoff=0;m_cofi=0.1;UpdateDisplayO;}voidCCalculatorDlg::UpdateDisplay(){if(GetSafeHwnd()==NULL)return;if(m_errorState!=ErrNone)m_result=n除数不能为零“;else{floatlVal=(m_bOperandAvail)?m_operand:m_accum;m_result.Format(_T(n%r),lVa1);inti=m_result.GetLength();while(m_result.GetAt(i-l)==,O'){m_result.Delete(i-l,l);i-=l;}}UpdateData(FALSE);}BOOLCCalculatorDlg::Keyboard(LPCTSTRszButton){switch(szButton[0]){case'c':caseC:OnClear();break;case7':OnDivid();break;caseOnAdd();break;caseOnMinus();break;caseOnMultiplyO;break;case=1:OnEqual();break;default:if(szButton[0]>='O'&&szButton[0]<=9)if(m_errorState!=ErrNone)returnFALSE;if(!m_bOperandAvail)m_operand=0;m_operand=m_operand*10+szButton[0]・O;m_bOperandAvail=TRUE;UpdateDisplayO;elsereturnFALSE;break;returnTRUE;voidCCalculatorDlg::OnAdd(){//TODO:AddyourcontrolnotificationhandlercodehereCalculate();m_operator=OpAdd;voidCCalculatorDlg::OnMinus(){//TODO:AddyourcontrolnotificationhandlercodehereCalculate();m_operator=OpSubtract;}voidCCalculatorDlg::OnDivid(){//TODO:AddyourcontrolnotificationhandlercodehereCalculate();m_operator=OpDivide;voidCCalculatorDlg::OnMultiply(){//TODO:AddyourcontrolnotificationhandlercodehereCalculate();m_operator=OpMultiply;}voidCCalculatorDlg::OnEqual(){//TODO:AddyourcontrolnotificationhandlercodehereCalculate();m_operator=OpNone;voidCCalculatorDlg::OnSign()//TODO:Addyourcontrolnotificationhandlercodeherem_operand*=-l;UpdateDisplay();}voidCCalculatorDlg::OnSqrt(){//TODO:Addyourcontrolnotificationhandlercodeherem_func=FuncSqrt;Run_Func();}voidCCalculatorDlg::OnReciprocal(){//TODO:Addyourcontrolnotificationhandlercodeherem_iunc=FuncRec;Run_Func();}voidCCalculatorDlg::OnPoint(){//TODO:Addyourcontrolnotificationhandlercodeherem_bCoff=l;UpdateDisplayO;}voidCCalculatorDlg::OnClear(){//TODO:Addyourcontrolnotificationhandlercodeherem_operator=OpNone;m_operand=0;m_accum=0;m_bOperandAvail=FALSE;m_errorState=ErrNone;m_cofl^=0.1;UpdateDisplayO;}BOOLCCalculatorDlg::PreTranslateMessage(MSG*pMsg){if(m_hAccel!=NULL&&TranslateAccelerator(m_hWnd,m_hAccel,pMsg))returnTRUE;returnCDialog::PreTranslateMessage(pMsg);}voidCCalculatorDlg::OnLog(){//TODO:Addyourcontrolnotificationhandlercodeherem_func=FuncLog;Run_Func();}voidCCalculatorDlg::OnLn(){//TODO:Addyourcontrolnotificationhandlercodeherem_lunc=FuncLn;Run_Func();}voidCCalculatorDlg::OnFactoria1(){//TODO:Addyourcontrolnotificationhandlercodeherem_iunc=FuncN;Run_Func();voidCCalculatorDlg::OnExp(){//TODO:Addyourcontrolnotificationhandlercodeherem_func=FuncExp;Run_Func();}voidCCalculatorDlg::OnSentitic(){//TODO:Addyourcontrolnotificationhandlercodeherem_bIsExpand=l;m_sentific=O;ExpandToSentific();}voidCCalculatorDlg::OnSin(){//TODO:Addyourcontrolnotificationhandlercodeherem_iunc=FuncSin;Run_Func();}voidCCalculatorDlg::OnSquar(){//TODO:Addyourcontrolnotificationhandlercodeherem_iunc=FuncSqre;Run_Func();}voidCCalculatorDlg::OnTan(){//TODO:Addyourcontrolnotificationhandlercodeherem_func=FuncTan;Run_Func();}voidCCalculatorDlg::OnStandard(){//TODO:Addyourcontrolnotificationhandlercodeherem_bIsExpand=O;m_sentific=l;ExpandToSentific();}voidCCalculatorDlg::Run_Func(){if(m_errorState!=ErrNone)return;if(m_bOperandAvail){if(m_lunc==FuncExp)m_operand=exp(m_operand);if(m_tunc==FuncLn)m_operand=log(m_operand);if(m_func==FuncLog)m_operand=log10(m_operand);if(m_tunc==FuncSqrt)m_operand=sqrt(m_operand);if(m_lunc==FuncSqre)m_operand=pow(10,m_operand);if(m_tunc==FuncSin)m_operand=sin(m_operand*DtoR);if(m_tunc==FuncCos)m_operand=cos(m_operand*DtoR);if(m_tunc==FuncTa
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 达州桥梁介绍
- 中考语文文言文对比阅读(全国)10 《陋室铭》对比阅读(15组73题)(原卷版)
- 物业现场人员安排方案范文
- 辩论社培训教学课件
- 车险理赔培训课件案例
- 车队春节期间安全培训课件
- 车队安全教育培训制度
- 落实纪检监察巡察工作高质量发展《五年行动方案》
- 2026年食品检验工(高级)模拟试题含答案
- 酒店员工绩效考核与晋升制度
- m的认主协议书
- 生蚝课件教学课件
- 2025年及未来5年市场数据中国机电安装工程市场调查研究及行业投资潜力预测报告
- 2025年湖南省公务员录用考试《申论》真题(县乡卷)及答案解析
- kv高压线防护施工方案
- 住建局执法证考试题库及答案2025
- 主管护师聘任述职报告
- AI搜索时代:从GEO到AIBE的品牌新蓝图
- 产品知识培训会议总结
- 与业主沟通技巧培训
- 专题11 圆(安徽专用)5年(2021-2025)中考1年模拟《数学》真题分类汇编
评论
0/150
提交评论