软件课程设计 第三阶段 实验报告.docx
- 文档编号:29668825
- 上传时间:2023-07-26
- 格式:DOCX
- 页数:39
- 大小:218.34KB
软件课程设计 第三阶段 实验报告.docx
《软件课程设计 第三阶段 实验报告.docx》由会员分享,可在线阅读,更多相关《软件课程设计 第三阶段 实验报告.docx(39页珍藏版)》请在冰豆网上搜索。
软件课程设计第三阶段实验报告
编号:
()字号
《软件课程设计》报告
中国矿业大学计算机科学与技术学院
年月
软件课程设计任务书
专业年级:
学生姓名:
任务下达日期:
200年月日
课程设计日期:
200年月日至200年月日
课程设计题目:
面向过程
类别
题目序号
成绩
图形界面
1.迭代法求a的立方根
2.面向对象实现复数运算
软件课程设计指导教师评阅书
指导教师评语(①基础理论及基本技能的掌握;②独立解决实际问题的能力;③研究内容的理论依据和技术方法;④取得的主要成果及创新点;⑤工作态度及工作量;⑥总体评价及建议成绩;⑦存在问题等):
成绩:
指导教师签字:
年月日
目录
五、图形界面1-----迭代法求a的立方根(MFC迭代法求a的立方根.rar)
5.1需求分析……………………………………………………………………….…4
5.2概要设计………………………………………………………………………...4
5.3详细设计与编码………………………………………………………………...4
5.4调试分析………………………………………………………………………...13
5.5用户使用说明………………………………………………………………….14
5.6设计心得………………………………………………………………………...14
六、图形界面2----面向对象实现复数运算(MFC复数类实现.rar)
6.1需求分析……………………………………………………………………….…14
6.2概要设计………………………………………………………………………...15
6.3详细设计与编码………………………………………………………………...15
6.4调试分析………………………………………………………………………...26
6.5用户使用说明…………………………………………………………………29
6.6设计心得………………………………………………………………………...29
5.1需求分析
本程序以MFC的形式进行编程,在更加清楚的页面下进行操作,并通过加入按钮、输入框、文本等控件,对控件加入函数以实现计算立方根功能(通过迭代法计算输入值的立方根)。
输入形式:
Double型数据
输出形式:
Double型数据
测试的数据:
输入:
16
输出:
2.51984211029563
5.2概要设计
首先给编辑框绑定一个Double型变量m_a用来输入,给另外一个编辑框绑定一个Double型变量m_X用来输出。
定义一个double型便令Xi用来进行数据平移。
对“开立方”按钮添加事件的响应函数voidCADlg:
:
OnButton()以实现该程序的功能
因为该程序较简单,所以只有一个主函数,在主函数中直接使用do~while语句进行数据平移,直至所求数据符合要求为止。
5.3详细设计与编码
主函数流程图:
主要编码:
//迭代法求a的立方根Dlg.cpp:
implementationfile
//
#include"stdafx.h"
#include"迭代法求a的立方根.h"
#include"迭代法求a的立方根Dlg.h"
#ifdef_DEBUG
#definenewDEBUG_NEW
#undefTHIS_FILE
staticcharTHIS_FILE[]=__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//CAboutDlgdialogusedforAppAbout
doublefabs(double);
classCAboutDlg:
publicCDialog
{
public:
CAboutDlg();
//DialogData
//{{AFX_DATA(CAboutDlg)
enum{IDD=IDD_ABOUTBOX};
//}}AFX_DATA
//ClassWizardgeneratedvirtualfunctionoverrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtualvoidDoDataExchange(CDataExchange*pDX);//DDX/DDVsupport
//}}AFX_VIRTUAL
//Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_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_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//CADlgdialog
CADlg:
:
CADlg(CWnd*pParent/*=NULL*/)
:
CDialog(CADlg:
:
IDD,pParent)
{
//{{AFX_DATA_INIT(CADlg)
m_a=0.0;
m_X=0.0;
//}}AFX_DATA_INIT
//NotethatLoadIcondoesnotrequireasubsequentDestroyIconinWin32
m_hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
voidCADlg:
:
DoDataExchange(CDataExchange*pDX)
{
CDialog:
:
DoDataExchange(pDX);
//{{AFX_DATA_MAP(CADlg)
DDX_Text(pDX,kaifangzhia,m_a);
DDX_Text(pDX,shuchuzhi,m_X);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CADlg,CDialog)
//{{AFX_MSG_MAP(CADlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON,OnButton)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//CADlgmessagehandlers
BOOLCADlg:
:
OnInitDialog()
{
CDialog:
:
OnInitDialog();
//Add"About..."menuitemtosystemmenu.
//IDM_ABOUTBOXmustbeinthesystemcommandrange.
ASSERT((IDM_ABOUTBOX&0xFFF0)==IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX<0xF000);
CMenu*pSysMenu=GetSystemMenu(FALSE);
if(pSysMenu!
=NULL)
{
CStringstrAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if(!
strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING,IDM_ABOUTBOX,strAboutMenu);
}
}
//Settheiconforthisdialog.Theframeworkdoesthisautomatically
//whentheapplication'smainwindowisnotadialog
SetIcon(m_hIcon,TRUE);//Setbigicon
SetIcon(m_hIcon,FALSE);//Setsmallicon
//TODO:
Addextrainitializationhere
returnTRUE;//returnTRUEunlessyousetthefocustoacontrol
}
voidCADlg:
:
OnSysCommand(UINTnID,LPARAMlParam)
{
if((nID&0xFFF0)==IDM_ABOUTBOX)
{
CAboutDlgdlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog:
:
OnSysCommand(nID,lParam);
}
}
//Ifyouaddaminimizebuttontoyourdialog,youwillneedthecodebelow
//todrawtheicon.ForMFCapplicationsusingthedocument/viewmodel,
//thisisautomaticallydoneforyoubytheframework.
voidCADlg:
:
OnPaint()
{
if(IsIconic())
{
CPaintDCdc(this);//devicecontextforpainting
SendMessage(WM_ICONERASEBKGND,(WPARAM)dc.GetSafeHdc(),0);
//Centericoninclientrectangle
intcxIcon=GetSystemMetrics(SM_CXICON);
intcyIcon=GetSystemMetrics(SM_CYICON);
CRectrect;
GetClientRect(&rect);
intx=(rect.Width()-cxIcon+1)/2;
inty=(rect.Height()-cyIcon+1)/2;
//Drawtheicon
dc.DrawIcon(x,y,m_hIcon);
}
else
{
CDialog:
:
OnPaint();
}
}
//Thesystemcallsthistoobtainthecursortodisplaywhiletheuserdrags
//theminimizedwindow.
HCURSORCADlg:
:
OnQueryDragIcon()
{
return(HCURSOR)m_hIcon;
}
voidCADlg:
:
OnButton()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
UpdateData(true);//检索输入
doubleXi;
Xi=m_a;
do//进行迭代求开方值
{
m_X=Xi;
Xi=(2*m_X+m_a/(m_X*m_X))/3;
}
while(fabs(Xi-m_X)>=0.00001);
UpdateData(false);//检索输出
}
其他文件中代码
//迭代法求a的立方根.cpp:
Definestheclassbehaviorsfortheapplication.
//
#include"stdafx.h"
#include"迭代法求a的立方根.h"
#include"迭代法求a的立方根Dlg.h"
#ifdef_DEBUG
#definenewDEBUG_NEW
#undefTHIS_FILE
staticcharTHIS_FILE[]=__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//CAApp
BEGIN_MESSAGE_MAP(CAApp,CWinApp)
//{{AFX_MSG_MAP(CAApp)
//NOTE-theClassWizardwilladdandremovemappingmacroshere.
//DONOTEDITwhatyouseeintheseblocksofgeneratedcode!
//}}AFX_MSG
ON_COMMAND(ID_HELP,CWinApp:
:
OnHelp)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//CAAppconstruction
CAApp:
:
CAApp()
{
//TODO:
addconstructioncodehere,
//PlaceallsignificantinitializationinInitInstance
}
/////////////////////////////////////////////////////////////////////////////
//TheoneandonlyCAAppobject
CAApptheApp;
/////////////////////////////////////////////////////////////////////////////
//CAAppinitialization
BOOLCAApp:
:
InitInstance()
{
AfxEnableControlContainer();
//Standardinitialization
//Ifyouarenotusingthesefeaturesandwishtoreducethesize
//ofyourfinalexecutable,youshouldremovefromthefollowing
//thespecificinitializationroutinesyoudonotneed.
#ifdef_AFXDLL
Enable3dControls();//CallthiswhenusingMFCinasharedDLL
#else
Enable3dControlsStatic();//CallthiswhenlinkingtoMFCstatically
#endif
CADlgdlg;
m_pMainWnd=&dlg;
intnResponse=dlg.DoModal();
if(nResponse==IDOK)
{
//TODO:
Placecodeheretohandlewhenthedialogis
//dismissedwithOK
}
elseif(nResponse==IDCANCEL)
{
//TODO:
Placecodeheretohandlewhenthedialogis
//dismissedwithCancel
}
//Sincethedialoghasbeenclosed,returnFALSEsothatweexitthe
//application,ratherthanstarttheapplication'smessagepump.
returnFALSE;
}
//stdafx.h:
includefileforstandardsystemincludefiles,
//orprojectspecificincludefilesthatareusedfrequently,but
//arechangedinfrequently
//
#if!
defined(AFX_STDAFX_H__75440762_4CDB_47D9_AC6C_7D3C9F3CDCA9__INCLUDED_)
#defineAFX_STDAFX_H__75440762_4CDB_47D9_AC6C_7D3C9F3CDCA9__INCLUDED_
#if_MSC_VER>1000
#pragmaonce
#endif//_MSC_VER>1000
#defineVC_EXTRALEAN//Excluderarely-usedstufffromWindowsheaders
#include
#include
#include
#include
#ifndef_AFX_NO_AFXCMN_SUPPORT
#include
#endif//_AFX_NO_AFXCMN_SUPPORT
#include"math.h"
//{{AFX_INSERT_LOCATION}}
//MicrosoftVisualC++willinsertadditionaldeclarationsimmediatelybeforethepreviousline.
#endif//!
defined(AFX_STDAFX_H__75440762_4CDB_47D9_AC6C_7D3C9F3CDCA9__INCLUDED_)
//迭代法求a的立方根.h:
mainheaderfileforthe迭代法求A的立方根application
//
#if!
defined(AFX_A_H__7B02BE33_C271_45E2_8AB6_0DEE2488B81D__INCLUDED_)
#defineAFX_A_H__7B02BE33_C271_45E2_8AB6_0DEE2488B81D__INCLUDED_
#if_MSC_VER>1000
#pragmaonce
#endif//_MSC_VER>1000
#ifndef__AFXWIN_H__
#errorinclude'stdafx.h'beforeincludingthisfileforPCH
#endif
#include"resource.h"//mainsymbols
/////////////////////////////////////////////////////////////////////////////
//CAApp:
//See迭代法求a的立方根.cppfortheimplementationofthisclass
//
classCAApp:
publicCWinApp
{
public:
CAApp();
//Overrides
//ClassWizardgeneratedvirtualfunctionoverrides
//{{AFX_VIRTUAL(CAApp)
public:
virtualBOOLInitInstance();
//}}AFX_VIRTUAL
//Implementation
//{{AFX_MSG(CAApp)
//NOTE-theClassWizardwilladdandremovememberfunctionshere.
//DONOTEDITwhatyouseeintheseblocksofgeneratedcode!
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
//MicrosoftVisualC++willinsertadditionaldeclarationsimmediatelybeforethepreviousline.
#endif//!
defined(AFX_A_H__7B02BE33_C271_45E2_8AB6_0DEE2488B81D__INCLUDED_)
5.4调试分析
(只有正确的输入结果,无错误的输入结果)
因程序简单,在运行时并未产生错误。
5.5用户使用说明
在第一个输入框输入一个数即可(不限正负)
点击“开立方”即可在Outp
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 软件课程设计 第三阶段 实验报告 软件 课程设计 第三 阶段 实验 报告