计算器设计报告 简易计算器的设计报告.docx

上传人:h**** 文档编号:26996897 上传时间:2022-07-21 格式:DOCX 页数:13 大小:14.27KB
返回 下载 相关 举报
计算器设计报告 简易计算器的设计报告.docx_第1页
第1页 / 共13页
计算器设计报告 简易计算器的设计报告.docx_第2页
第2页 / 共13页
点击查看更多>>
资源描述

《计算器设计报告 简易计算器的设计报告.docx》由会员分享,可在线阅读,更多相关《计算器设计报告 简易计算器的设计报告.docx(13页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、计算器设计报告 简易计算器的设计报告.docx 计算器设计报告简易计算器的设计报告 计算器的设计 1概述 1.1 课程设计目的 1、巩固并加深学生对C+语言程序设计知识的理解; 2、培养学生面向对象的程序设计思想,使学生认识面向过程和面向对象两种设计方法的区别; 3、进一步掌握和应用VC+ 6.0集成开发环境; 4、提高运用C+语言解决实际问题的能力; 5、初步掌握开发小型实用软件的基本方法,能独立设计、实现基本的MIS系统; 6、掌握书写程序设计开发文档的能力(书写课程设计实验报告)。 1.2 课程设计内容 课题名称:计算器的实现 说明:实现一个计算器。 要求: 用“计算器”的标准视图执行简

2、单的计算。 3 四则代码如下 void CCALDlg:OnButtonequal() / TODO: Add your control notification handler code here UpdateData(TRUE); num2 =m_str; if(num2=0&ope=3) m_str1=除数不能为零; m_str =0; num1 = 0; num2 = 0; UpdateData(FALSE); else / int f = 0; switch (ope) /加 case 0: m_str = num1 + num2; peak; /减 case 1: m_str =

3、num1 - num2; peak; 5 4系统详细设计 4.1 设计步骤 打开Microsoft Visual C+ 6.0,在文件中点击新建,在弹出框内选择MFC AppWizardexe工程,输入工程名yeyahui及其所在位置,点击确定,如图4- 1所示。 图4-1 新建MFC AppWizardexe工程 将弹出MFC AppWizard-step 1对话框,选择基本对话框,点击完成,如图4-2所示。 7 图4-3新建的对话框 4.2 界面设计 界面设计主要是创建控件,在图4-3所示的Resoure View选项卡中打开Dialog资源组,双击IDD_ZHOUTONG_DIALOG,

4、在右边的窗口中显示出待编辑的对话框。开始摆放控件,包括编辑框和按钮的创建。按钮的创建以“1”为例进行介绍,其他按钮的创建可参照此进行操作。 1)在图4- 3中Controls的“编辑框”按钮上单击鼠标左键,在对话框编辑窗口上合适的位置按下鼠标左键并拖动鼠标画出一个大小合适的编辑框。在编辑框上单击鼠标右键,在弹出的快捷莱单中选择属性选项,此时弹出Edit属性对话框,如图4-4所示,在该对话框中输入ID属性。 9 图5-1 四则运算,乘法测试结果图 13 附录 附录1 源程序清单 / 计算器Dlg.cpp : implementation file / #include stdafx.h #inc

5、lude CAL.h #include CALDlg.h #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE = _FILE_; #endif / / CAboutDlg dialog used for App About class CAboutDlg : public CDialog public: CAboutDlg(); / Dialog Data /AFX_DATA(CAboutDlg) enum IDD = IDD_ABOUTBOX ; /AFX_DATA / ClassWizard

6、generated virtual function overrides /AFX_VIRTUAL(CAboutDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); / DDX/DDV support /AFX_VIRTUAL / Implementation protected: /AFX_MSG(CAboutDlg) /AFX_MSG DECLARE_MESSAGE_MAP() ; CAboutDlg:CAboutDlg() : CDialog(CAboutDlg:IDD) /AFX_DATA_INIT(CAbou

7、tDlg) /AFX_DATA_INIT void CAboutDlg:DoDataExchange(CDataExchange* pDX) CDialog:DoDataExchange(pDX); /AFX_DATA_MAP(CAboutDlg) /AFX_DATA_MAP 15 / CCALDlg message handlers BOOL CCALDlg:OnInitDialog() CDialog:OnInitDialog(); / Add About. menu item to system menu. / IDM_ABOUTBOX must be in the system com

8、mand range. ASSERT(IDM_ABOUTBOX & 0xFFF0) = IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) CString strAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); if (!strAboutMenu.IsEmpty() pSysMenu-AppendMenu(MF_SEPARATOR); pSysMenu-AppendMenu(MF_STRING, IDM_

9、ABOUTBOX, strAboutMenu); / Set the icon for this dialog. The framework does this automatically / when the applications main window is not a dialog SetIcon(m_hIcon, TRUE);/ Set big icon SetIcon(m_hIcon, FALSE);/ Set small icon SetWindowText(_T(计算器 V1.0 作者:13级数学与计算机学院第4期陈菁);/修改软件名称 / TODO: Add extra i

10、nitialization here return TRUE; / return TRUE unless you set the focus to a control void CCALDlg:OnSysCommand(UINT nID, LPARAM lParam) if (nID & 0xFFF0) = IDM_ABOUTBOX) CAboutDlg dlgAbout; dlgAbout.DoModal(); else CDialog:OnSysCommand(nID, lParam); / If you add a minimize button to your dialog, you

11、will need the code below / to draw the icon. For MFC applications using the document/view model, / this is automatically done for you by the framework. void CCALDlg:OnPaint() if (IsIconic() CPaintDC dc(this); / device context for painting 17 void CCALDlg:OnButton3() / TODO: Add your control notifica

12、tion handler code hereUpdateData(TRUE); m_str =0; m_str=m_str+3; UpdateData(FALSE); void CCALDlg:OnButton4() / TODO: Add your control notification handler code hereUpdateData(TRUE); m_str =0; m_str=m_str+4; UpdateData(FALSE); void CCALDlg:OnButton5() / TODO: Add your control notification handler cod

13、e hereUpdateData(TRUE); m_str =0; m_str=m_str+5; UpdateData(FALSE); void CCALDlg:OnButton6() / TODO: Add your control notification handler code hereUpdateData(TRUE); m_str =0; m_str=m_str+6; UpdateData(FALSE); void CCALDlg:OnButton7() / TODO: Add your control notification handler code hereUpdateData

14、(TRUE); m_str =0; m_str=m_str+7; UpdateData(FALSE); void CCALDlg:OnButton8() / TODO: Add your control notification handler code hereUpdateData(TRUE); m_str =0; 19 else / int f = 0; switch (ope) /加 case 0: m_str = num1 + num2; peak; /减 case 1: m_str = num1 - num2; peak; case 2: m_str = num1 * num2; p

15、eak; case 3: m_str = num1 / num2; peak; case 4: m_str = num1 * num1; UpdateData(FALSE); void CCALDlg:OnButtonmul() / TODO: Add your control notification handler code hereSaveValue1(); ope=2; void CCALDlg:OnButtondiv() / TODO: Add your control notification handler code hereSaveValue1(); ope=3; void CCALDlg:OnButton10() / TODO: Add your control notification handler code herenum1=m_str; ope=4; 21

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 应用文书 > 策划方案

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com