版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、22VC+計(jì)算器課程設(shè)計(jì)報(bào)告1.作品名稱:計(jì)算器2.本次課程設(shè)計(jì)的目的 在程序設(shè)計(jì)中,通過設(shè)計(jì)、編制、調(diào)試一個(gè)模擬計(jì)算器的程序,加深對(duì)語法及語義分析原理的理解,并 實(shí)現(xiàn)對(duì)命令語句的靈活應(yīng)用。3.主要功能實(shí)現(xiàn)計(jì)算器的功能。用戶根據(jù)程序提示,輸入數(shù)字或字符,選擇要進(jìn)行的運(yùn)算,可以進(jìn)行正弦、余弦、正切、開方、對(duì)數(shù)、加、減、乘、除、華氏溫度與攝氏度之間的換算以及平方根的運(yùn)算。4.代碼#include <process.h>#include<time.h>#define MAX 100#include <iostream.h>#include <conio.h&
2、gt;#include <stdlib.h>#include <math.h>double number1,number2,answer,number3,num10000; int n,k=1;char input,val; class oopcalc private:double x,y; double fartocel(double number1); double celtofar(double number1); double sqroot(double number1);void calcsqr();void calccos();void calctan();
3、void calcsin();void calclog();public:double getX()return x;double getY()return y;double set()x=number1;y=number2;double calcadd(double number1,double number2); double calcsub(double number1,double number2); double calcdiv(double number1,double number2); double calcmult(double number1,double number2)
4、; void calcfartocel();void calcceltofar();void calcsroot();void exitprog();void menu();void caculate(); void test();void badinput(); ;void oopcalc:calcsin()cout<<"The Sin Functionn"cout<<"Enter a number:"cin>>number1;answer=sin(number1);cout<<"The sin
5、 of "<<number1<<" is "<<answer<<endl;cout<<"Press any key to continuen"getch();menu();void oopcalc:calccos()cout<<"The Cos Functionn"cout<<"Enter a number:"cin>>number1;answer=cos(number1);cout<<"
6、The cos of "<<number1<<" is "<<answer<<endl;cout<<"Press any key to continuen"getch();menu();void oopcalc:calctan()cout<<"The Tan Functionn"cout<<"Enter a number:"cin>>number1;answer=tan(number1);cout<<
7、;"The tan of "<<number1<<" is "<<answer<<endl;cout<<"Press any key to continuen"getch();menu();void oopcalc:calcsqr()cout<<"The sqr Functionn"cout<<"Enter a number:"cin>>number1;answer=(number1*number1)
8、;cout<<"The sqr of "<<number1<<" is "<<answer<<endl;cout<<"Press any key to continuen"getch();menu();void oopcalc:calclog()cout<<"The Log Functionn"cout<<"Enter a number:"cin>>number1;if(number1&l
9、t;=0) cout<<"Bad input!n"cout<<"Press any key to continuen"getch();menu();elseanswer=log(number1);cout<<"The log of "<<number1<<" is "<<answer<<endl;cout<<"Press any key to continuen"getch();menu();doub
10、le oopcalc:calcadd(double number1,double number2) answer=number1+number2;return(answer);double oopcalc:calcsub(double number1,double number2) answer = number1-number2;return(answer);double oopcalc:calcdiv(double number1,double number2) if(number2=0)getch();menu();elseanswer = number1/number2;return(
11、answer);double oopcalc:calcmult(double number1,double number2) answer = number1*number2;return(answer);void oopcalc:calcfartocel()cout << "The Farenheit to Celsius Functionn"cout << "Enter a tempature in Farenheit: "cin >> number1;answer =(number1 - 32) * 5) / 9
12、;cout << "The tempature in Celsius is " << answer << endl;cout << "Press any key to continuen"getch();menu();void oopcalc:calcceltofar()cout << "The Celsius to Farenheit Functionn"cout << "Enter a tempature in Celsius: "cin
13、>> number1;answer =number1 * 9 / 5 + 32;cout << "The tempature in Farenheit is " << answer << endl;cout << "Press any key to continuen"getch();menu();void oopcalc:calcsroot()cout << "The Square Root Functionn"cout << "First
14、 number: "cin >> number1;if(number1<0) cout<<"your enter is incorrect,please enter a new numbern"getch();menu();elseanswer = sqrt(number1);cout << "The square root of " << number1 << " is " << answer << endl;cout <<
15、; "Press any key to continuen"getch();menu();void oopcalc:exitprog()exit(-1);void oopcalc:menu()oopcalc a;system("cls"); cout << "=MENU=n"cout <<"s:選擇s進(jìn)行正弦運(yùn)算n"cout <<"c:選擇c進(jìn)行余弦運(yùn)算n"cout <<"t:選擇t進(jìn)行正切運(yùn)算n"cout <<&q
16、uot;g:選擇g進(jìn)行對(duì)數(shù)運(yùn)算n"cout <<"n:選擇n進(jìn)行求平方運(yùn)算n"cout << "1: 選擇1進(jìn)行混合運(yùn)算n"cout << "2: 選擇2進(jìn)行華氏溫度轉(zhuǎn)化為攝氏溫度的運(yùn)算n"cout << "3: 選擇3進(jìn)行攝氏溫度轉(zhuǎn)化為華氏溫度的運(yùn)算n"cout << "4: 選擇4進(jìn)行求平方根運(yùn)算n"cout << "5: 選擇5進(jìn)行測(cè)試n"cout << "6:選擇6
17、退出運(yùn)算n" cout << "請(qǐng)選擇: "cin >> input;cout << "=n"switch (input)case 's':case 'S':a.calcsin();break;case 'c': case 'C': a.calccos();break;case 't':case 'T': a.calctan();break;case 'g':case 'G':a.c
18、alclog();break;case 'n':case 'N':a.calcsqr();break;case '1':a.caculate();break;case '2':a.calcfartocel();break;case '3':a.calcceltofar();break;case '4':a.calcsroot();break;case '5': a.test();break;case '6':a.exitprog();break;default :a.
19、badinput();void oopcalc:caculate() oopcalc a;cout<<"The Multifunction(混合四則運(yùn)算)n"for(int n=1;n+)cout<<"Number"<<n<<"(Enter 0 to end entering):"cin>>numnif(numn=0)cout<<"Press any key to continuen"getch();menu();switch(k)case 1
20、:if(n=1)answer=num1;break;else answer=a.calcadd(answer,numn); cout<<"The answer is "<<answer<<endl;break;case 2:if(n=1)answer=num1;break;else answer=a.calcsub(answer,numn);cout<<"The answer is "<<answer<<endl;break;case 3:if(n=1)answer=num1;bre
21、ak;else answer=a.calcmult(answer,numn);cout<<"The answer is "<<answer<<endl;break;case 4:if(n=1)answer=num1;break;else answer=a.calcdiv(answer,numn);cout<<"The answer is "<<answer<<endl;break;label1:cout<<"Please choose the function
22、you want(+ or - or * or /):n"cin>>val;switch(val)case'+':k=1;break;case'-':k=2;break;case'*':k=3;break;case'/':k=4;break;default:cout<<"Bad input!n"goto label1;void oopcalc:test()cout<<"The Test Functionn"int s;float p;s=rand
23、()%4+1;srand ( time (NULL) );number1=rand()%MAX+1;number2=rand()%MAX+1;switch(s)case 1:cout<<number1<<'+'<<number2<<'='answer=calcadd(number1,number2);break;case 2:cout<<number1<<'-'<<number2<<'='answer=calcsub(number1,number2);break;case 3:cout<<number1<<'/'<<number2<<'='answer=calcdiv(number1,number2);break;case 4:cout&
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 染色體病檢測(cè)指南及規(guī)范
- 企業(yè)年金管理效率提升研究
- 汽車露營(yíng)地裝修施工合同范本格式
- 供應(yīng)鏈協(xié)同管理方案
- 科技清水池防水施工合同
- 電力公司總經(jīng)理勞動(dòng)合同范例
- 旅游管理專業(yè)教師聘用合同
- 漁業(yè)公司電工招聘及維護(hù)協(xié)議
- 醫(yī)療捐贈(zèng)物品使用準(zhǔn)則
- 健康管理中心健身房租賃協(xié)議
- 爆破片日常檢查及定期更換記錄
- 運(yùn)轉(zhuǎn)車間鋼包管理制度
- 銷售大戶監(jiān)管辦法
- 小型裝配式冷庫(kù)設(shè)計(jì)(全套圖紙)
- 西師版小學(xué)數(shù)學(xué)二年級(jí)上冊(cè)半期考試
- 八六版高中英語課文全集
- 審計(jì)工作手冊(cè)
- 胰腺癌一病一品知識(shí)分享
- 【原創(chuàng)】《基于地理實(shí)踐力培養(yǎng)的校本課程開發(fā)研究》中期報(bào)告
- 公司下屬?gòu)S部推行5S管理通知
- (最新)13《金稅三期工程運(yùn)維架構(gòu)設(shè)計(jì)方案》V10
評(píng)論
0/150
提交評(píng)論