功能
用到的觀念
CODE
/*PROGRAMMER :楊翔斌*/
/*DATE :2009-10-08*/
/*FILENAME :HW01A002.cpp*/
/*DESCRIPTION:攝氏華氏換算*/
#include<iostream>//標頭檔
#include<iomanip>
using namespace std;//Indicates where header file is located
using std::getline;
int main()
{
float cc,f,choice;//宣告變數 為浮點數
cout<<"enter degree in (1)Celsius(2)Fahrenheit";//tell you to enter the number
cin>>choice;//輸入存到choice
system("cls");//clean the screen
if(choice==1)//判斷choice 是1
{
cout<<"enter a number(Celsius) and it'll convert Celsius into Fahrenheit ";//
顯示內容
cin>>cc;//輸入存到cc
f=32+1.8*cc;//運算值存到f
cout<<f<<" Fahrenheit degree";//顯示內容
}
if(choice==2)
{
cout<<"enter a number(Fahrenheit) and it'll convert Fahrenheit into Celsius
";//顯示內容
cin>>f;//輸入存到f
cc=(f-32.00)/1.8;//運算值存到cc
cout<<cc<<" Celsius degree";//顯示內容
}
system("pause");//停止
return 0;//程式結束
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.7.59