標題:
電費計算機(一)
[打印本頁]
作者:
陳品肇
時間:
2019-1-11 13:34
標題:
電費計算機(一)
本帖最後由 陳品肇 於 2019-1-12 17:23 編輯
參考台灣電力公司所公怖的
電費計算表格
, 設計一個計算電費的小工具,
讓使用者輸入月份, 與該月份的用電度數, 電腦回應該月份的電費.
[attach]5750[/attach]
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
system("cls");
int degree,month;
float money;
cout<<"*** 電費計算機 ***"<<endl<<endl;
cout<<"請輸入月份: ";
cin>>month;
if(month>=6 && month<=9)
{
cout<<"用電度數: ";
cin>>degree;
if(degree>0 && degree<=120)
{
money=1.63*degree;
}else if(degree>120 && degree<=330)
{
money=1.63*120+2.38*(degree-120);
}else if(degree>330 && degree<=500)
{
money=1.63*120+2.38*(330-120)+3.52*(degree-330);
}else if(degree>500 && degree<=700)
{
money=1.63*120+2.38*(330-120)+3.52*(500-330)+4.8*(degree-500);
}else if(degree>700 && degree<=1000)
{
money=1.63*120+2.38*(330-120)+3.52*(500-330)+4.8*(700-500)+5.66*(degree-700);
}else if(degree>=1001)
{
money=1.63*120+2.38*(330-120)+3.52*(500-330)+4.8*(700-500)+5.66*(1000-700)+6.41*(degree-1000);
}else
{
cout<<"用電度數輸入錯誤!"<<endl;
system("pause");
goto re;
}
}else if((month>=10 && month<=12)||(month>=1 && month<=5))
{
cout<<"用電度數: ";
cin>>degree;
if(degree>0 && degree<=120)
{
money=1.63*degree;
}else if(degree>120 && degree<=330)
{
money=1.63*120+2.1*(degree-120);
}else if(degree>330 && degree<=500)
{
money=1.63*120+2.1*(330-120)+2.89*(degree-330);
}else if(degree>500 && degree<=700)
{
money=1.63*120+2.1*(330-120)+2.89*(500-330)+3.94*(degree-500);
}else if(degree>700 && degree<=1000)
{
money=1.63*120+2.1*(330-120)+2.89*(500-330)+3.94*(700-500)+4.6*(degree-700);
}else if(degree>=1001)
{
money=1.63*120+2.1*(330-120)+2.89*(500-330)+3.94*(700-500)+4.6*(1000-700)+5.03*(degree-1000);
}else
{
cout<<"用電度數輸入錯誤!"<<endl;
system("pause");
goto re;
}
}else
{
cout<<"月份輸入錯誤!"<<endl;
system("pause");
goto re;
}
cout<<endl<<"您要繳交的電費共 "<<money<<"元!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
陳柏霖
時間:
2019-1-12 17:03
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
system("cls");
int month ,mony;
float give;
cout<<"***歡迎使電費計算機***"<<endl<<endl;
cout<<"請輸入月份:";
cin>>month;
if(month>=6 && month<=9)
{
cout<<"用電度數:";
cin>>mony;
if(mony>=1 && mony<=120)
{
give=mony*1.63;
}else if(mony>=121 && mony<=330)
{
give=120*1.63+(mony-120)*2.38;
}else if(mony>=331 && mony<=500)
{
give=120*1.63+330*2.38+(mony-330)*3.52;
}else if(mony>=501 && mony<=700)
{
give=120*1.63+330*2.38+500*3.52+(mony-500)*4.8;
}else if(mony>=701 && mony<=1000)
{
give=120*1.63+330*2.38+500*3.52+700*4.8+(mony-700)*5.66;
}else if(mony>=1001)
{
give=120*1.63+330*2.38+500*3.52+700*4.8+1000*5.66+(mony-1000)*6.41;
}else
{
cout<<"輸入錯誤"<<endl;
system("pause");
goto re;
}
}else if((month>=1 && month<=5)|| (month>=10 && month<=12))
{
cout<<"用電度數:";
cin>>mony;
if(mony>=1 && mony<=120)
{
give=mony*1.63;
}else if(mony>=121 && mony<=330)
{
give=120*1.63+(mony-120)*2.1;
}else if(mony>=331 && mony<=500)
{
give=120*1.63+330*2.1+(mony-330)*2.89;
}else if(mony>=501 && mony<=700)
{
give=120*1.63+330*2.1+500*2.89+(mony-500)*3.94;
}else if(mony>=701 && mony<=1000)
{
give=120*1.63+330*2.1+500*2.89+700*3.94+(mony-700)*4.6;
}else if(mony>=1001)
{
give=120*1.63+330*2.1+500*2.89+700*3.94+1000*4.6+(mony-1000)*5.03;
}else
{
cout<<"輸入錯誤"<<endl;
system("pause");
goto re;
}
}else
{
cout<<"輸入錯誤"<<endl;
system("pause");
goto re;
}
cout<<"電費為"<<give<<endl;
system("pause");
return 0;
}
複製代碼
作者:
蔡季庭
時間:
2019-1-12 17:04
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
system("cls");
int degree,month;
float money;
cout<<"*** 電費計算機 ***"<<endl<<endl;
cout<<"請輸入月份: ";
cin>>month;
if(month>=6 && month<=9)
{
cout<<"用電度數: ";
cin>>degree;
if(degree>0 && degree<=120)
{
money=1.63*degree;
}else if(degree>120 && degree<=330)
{
money=1.63*120+2.38*(degree-120);
}else if(degree>330 && degree<=500)
{
money=1.63*120+2.38*(330-120)+3.52*(degree-330);
}else if(degree>500 && degree<=700)
{
money=1.63*120+2.38*(330-120)+3.52*(500-330)+4.8*(degree-500);
}else if(degree>700)
{
money=1.63*120+2.38*(330-120)+3.52*(500-330)+4.8*(700-500)+5.66*(degree-700);
}else
{
cout<<"用電度數輸入錯誤!"<<endl;
system("pause");
goto re;
}
}else if((month>=10 && month<=12)||(month>=1 && month<=5))
{
cout<<"用電度數: ";
cin>>degree;
if(degree>0 && degree<=120)
{
money=1.63*degree;
}else if(degree>120 && degree<=330)
{
money=1.63*120+2.1*(degree-120);
}else if(degree>330 && degree<=500)
{
money=1.63*120+2.1*(330-120)+2.89*(degree-330);
}else if(degree>500 && degree<=700)
{
money=1.63*120+2.1*(330-120)+2.89*(500-330)+3.94*(degree-500);
}else if(degree>700)
{
money=1.63*120+2.1*(330-120)+2.89*(500-330)+3.94*(700-500)+4.6*(degree-700);
}else
{
cout<<"用電度數輸入錯誤!"<<endl;
system("pause");
goto re;
}
}else
{
cout<<"月份輸入錯誤!"<<endl;
system("pause");
goto re;
}
cout<<endl<<"您要繳交的電費共 "<<money<<"元!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
譚詩澐
時間:
2019-1-12 17:15
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
system("cls");
int month, degree;
float money;
cout<<"*** 電費計算機 ***"<<endl<<endl;
cout<<"請輸入月份: ";
cin>>month;
if(month>=6 && month<=9)
{
cout<<123;
cout<<"用電度數: ";
cin>>degree;
if(degree>1 && degree<=120)
{
money = degree*1.63;
}else if(degree>121 && degree<=330)
{
money = 120*1.63+(degree-120)*2.38;
}else if(degree>331 && degree<=500)
{
money = 120*1.63+(330-120)*2.38+(degree-330)*3.52;
}else if(degree>501 && degree<=700)
{
money = 120*1.63+(330-120)*2.38+(500-330)*3.52+(degree-500)*4.80;
}else if(degree>701 && degree<=1000)
{
money = 120*1.63+(330-120)*2.38+(500-330)*3.52+(700-500)*4.80+(degree-500)*5.66;
}else if(degree>1001)
{
money = 120*1.63+(330-120)*2.38+(500-330)*3.52+(700-500)*4.80+(1000-700)*5.66+(degree-1000)*6.41;
}else
{
cout<<"!!!輸入錯誤!!"<<endl;
system("pause");
goto re;
}
}else if((month>=1 && month<=5) || (month>=10 && month<=12))
{
cout<<"用電度數: ";
cin>>degree;
if(degree>1 && degree<=120)
{
money = degree*1.63;
}else if(degree>121 && degree<=330)
{
money = 120*1.63+(degree-120)*2.10;
}else if(degree>331 && degree<=500)
{
money = 120*1.63+(330-120)*2.1+(degree-330)*2.89;
}else if(degree>501 && degree<=700)
{
money = 120*1.63+(330-120)*2.1+(500-330)*2.89+(degree-500)*3.94;
}else if(degree>701 && degree<=1000)
{
money = 120*1.63+(330-120)*2.1+(500-330)*2.89+(700-500)*3.94+(degree-500)*4.6;
}else if(degree>1001)
{
money = 120*1.63+(330-120)*2.1+(500-330)*2.89+(700-500)*3.94+(1000-700)*4.6+(degree-1000)*5.03;
}else
{
cout<<"!!!輸入錯誤!!"<<endl;
system("pause");
goto re;
}
}else
{
cout<<"!!!輸入錯誤!!"<<endl;
system("pause");
goto re;
}
cout<<"您要繳的電費:"<<money<<endl;
system("pause");
goto re;
system("pause");
return 0;
}
複製代碼
作者:
蔡依宸
時間:
2019-1-12 17:31
include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
system("cls");
int degree,month;
float money;
cout<<"*** 電費計算機 ***"<<endl<<endl;
cout<<"請輸入月份: ";
cin>>month;
if(month>=6 && month<=9)
{
cout<<"用電度數: ";
cin>>degree;
if(degree>0 && degree<=120)
{
money=1.63*degree;
}else if(degree>120 && degree<=330)
{
money=1.63*120+2.38*(degree-120);
}else if(degree>330 && degree<=500)
{
money=1.63*120+2.38*(330-120)+3.52*(degree-330);
}else if(degree>500 && degree<=700)
{
money=1.63*120+2.38*(330-120)+3.52*(500-330)+4.8*(degree-500);
}else if(degree>700 && degree<=1000)
{
money=1.63*120+2.38*(330-120)+3.52*(500-330)+4.8*(700-500)+5.66*(degree-700);
}else if(degree>=1001)
{
money=1.63*120+2.38*(330-120)+3.52*(500-330)+4.8*(700-500)+5.66*(1000-700)+6.41*(degree-1000);
}else
{
cout<<"用電度數輸入錯誤!"<<endl;
system("pause");
goto re;
}
}else if((month>=10 && month<=12)||(month>=1 && month<=5))
{
cout<<"用電度數: ";
cin>>degree;
if(degree>0 && degree<=120)
{
money=1.63*degree;
}else if(degree>120 && degree<=330)
{
money=1.63*120+2.1*(degree-120);
}else if(degree>330 && degree<=500)
{
money=1.63*120+2.1*(330-120)+2.89*(degree-330);
}else if(degree>500 && degree<=700)
{
money=1.63*120+2.1*(330-120)+2.89*(500-330)+3.94*(degree-500);
}else if(degree>700 && degree<=1000)
{
money=1.63*120+2.1*(330-120)+2.89*(500-330)+3.94*(700-500)+4.6*(degree-700);
}else if(degree>=1001)
{
money=1.63*120+2.1*(330-120)+2.89*(500-330)+3.94*(700-500)+4.6*(1000-700)+5.03*(degree-1000);
}else
{
cout<<"輸入錯誤!"<<endl;
system("pause");
goto re;
}
}else
{
cout<<"輸入錯誤!"<<endl;
system("pause");
goto re;
}
cout<<endl<<"您要繳交的電費共 "<<money<<"元!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
戴偉宸
時間:
2019-2-13 19:31
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
system("cls");
int degree,month;
float money;
cout<<"*** 電費計算機 ***"<<endl<<endl;
cout<<"請輸入月份: ";
cin>>month;
if(month>=6 && month<=9)
{
cout<<"用電度數: ";
cin>>degree;
if(degree>0 && degree<=120)
{
money=1.63*degree;
}
else if(degree>120 && degree<=330)
{
money=1.63*120+2.38*(degree-120);
}
else if(degree>330 && degree<=500)
{
money=1.63*120+2.38*(330-120)+3.52*(degree-330);
}
else if(degree>500 && degree<=700)
{
money=1.63*120+2.38*(330-120)+3.52*(500-330)+4.8*(degree-500);
}else if(degree>700 && degree<=1000)
{
money=1.63*120+2.38*(330-120)+3.52*(500-330)+4.8*(700-500)+5.66*(degree-700);
}
else if(degree>=1001)
{
money=1.63*120+2.38*(330-120)+3.52*(500-330)+4.8*(700-500)+5.66*(1000-700)+6.41*(degree-1000);
}
else
{
cout<<"用電度數輸入錯誤!"<<endl;
system("pause");
goto re;
}
}else if((month>=10 && month<=12)||(month>=1 && month<=5))
{
cout<<"用電度數: ";
cin>>degree;
if(degree>0 && degree<=120)
{
money=1.63*degree;
}
else if(degree>120 && degree<=330)
{
money=1.63*120+2.1*(degree-120);
}
else if(degree>330 && degree<=500)
{
money=1.63*120+2.1*(330-120)+2.89*(degree-330);
}
else if(degree>500 && degree<=700)
{
money=1.63*120+2.1*(330-120)+2.89*(500-330)+3.94*(degree-500);
}
else if(degree>700 && degree<=1000)
{
money=1.63*120+2.1*(330-120)+2.89*(500-330)+3.94*(700-500)+4.6*(degree-700);
}
else if(degree>=1001)
{
money=1.63*120+2.1*(330-120)+2.89*(500-330)+3.94*(700-500)+4.6*(1000-700)+5.03*(degree-1000);
}
else
{
cout<<"用電度數輸入錯誤!"<<endl;
system("pause");
goto re;
}
}
else
{
cout<<"月份輸入錯誤!"<<endl;
system("pause");
goto re;
}
cout<<endl<<"您要繳交的電費共 "<<money<<"元!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
戴安利
時間:
2019-2-13 19:32
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
system("cls");
int degree,month;
float pay;
cout<<"*****電費計算機*****"<<endl<<endl;
cout<<"請輸入月份: ";
cin>>month;
if(month>=6 && month<=9)
{
cout<<"用電度數: ";
cin>>degree;
if(degree>0 && degree<=120)
{
pay = 1.63*degree;
}
else if(degree>120 && degree<=330)
{
pay = 1.63*120+2.38*(degree-120);
}
else if(degree>330 && degree<=500)
{
pay = 1.63*120+2.38*(330-120)+3.52*(degree-330);
}
else if(degree>500 && degree<=700)
{
pay = 1.63*120+2.38*(330-120)+3.52*(500-330)+4.8*(degree-500);
}
else if(degree>700 && degree<=1000)
{
pay = 1.63*120+2.38*(330-120)+3.52*(500-330)+4.8*(700-500)+5.66*(degree-700);
}
else if(degree>=1001)
{
pay = 1.63*120+2.38*(330-120)+3.52*(500-330)+4.8*(700-500)+5.66*(1000-700)+6.41*(degree-1000);
}
else
{
cout<<"電腦輸入錯誤!!!"<<endl;
}
system ("pause");
goto re;
}
else if((month>=10 && month<=12)||(month>=1 && month<=5))
{
cout<<"用電度數: ";
cin>>degree;
if(degree>0 && degree<=120)
{
pay = 1.63*degree;
}
else if(degree>120 && degree<=330)
{
pay = 1.63*120+2.1*(degree-120);
}
else if(degree>330 && degree<=500)
{
pay = 1.63*120+2.1*(330-120)+2.89*(degree-330);
}
else if(degree>500 && degree<=700)
{
pay = 1.63*120+2.1*(330-120)+2.89*(500-330)+3.94*(degree-500);
}
else if(degree>700 && degree<=1000)
{
pay = 1.63*120+2.1*(330-120)+2.89*(500-330)+3.94*(700-500)+4.6*(degree-700);
}
else if(degree>=1001)
{
pay = 1.63*120+2.1*(330-120)+2.89*(500-330)+3.94*(700-500)+4.6*(1000-700)+5.03*(degree-1000);
}
else
{
cout<<"用電度數輸入錯誤!!!"<<endl;
system("pause");
goto re;
}
}else
{
cout<<"月份輸入錯誤!"<<endl;
system("pause");
goto re;
}
cout<<endl<<"您要繳交的電費共 "<<pay<<"元!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
戴唯陞
時間:
2019-2-13 19:33
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
system("cls");
int degree,month;
float money;
cout<<"*** 電費計算機 ***"<<endl<<endl;
cout<<"請輸入月份: ";
cin>>month;
if(month>=6 && month<=9)
{
cout<<"用電度數: ";
cin>>degree;
if(degree>0 && degree<=120)
{
money=1.63*degree;
}else if(degree>120 && degree<=330)
{
money=1.63*120+2.38*(degree-120);
}else if(degree>330 && degree<=500)
{
money=1.63*120+2.38*(330-120)+3.52*(degree-330);
}else if(degree>500 && degree<=700)
{
money=1.63*120+2.38*(330-120)+3.52*(500-330)+4.8*(degree-500);
}else if(degree>700 && degree<=1000)
{
money=1.63*120+2.38*(330-120)+3.52*(500-330)+4.8*(700-500)+5.66*(degree-700);
}else if(degree>=1001)
{
money=1.63*120+2.38*(330-120)+3.52*(500-330)+4.8*(700-500)+5.66*(1000-700)+6.41*(degree-1000);
}else
{
cout<<"用電度數輸入錯誤!"<<endl;
system("pause");
goto re;
}
}else if((month>=10 && month<=12)||(month>=1 && month<=5))
{
cout<<"用電度數: ";
cin>>degree;
if(degree>0 && degree<=120)
{
money=1.63*degree;
}else if(degree>120 && degree<=330)
{
money=1.63*120+2.1*(degree-120);
}else if(degree>330 && degree<=500)
{
money=1.63*120+2.1*(330-120)+2.89*(degree-330);
}else if(degree>500 && degree<=700)
{
money=1.63*120+2.1*(330-120)+2.89*(500-330)+3.94*(degree-500);
}else if(degree>700 && degree<=1000)
{
money=1.63*120+2.1*(330-120)+2.89*(500-330)+3.94*(700-500)+4.6*(degree-700);
}else if(degree>=1001)
{
money=1.63*120+2.1*(330-120)+2.89*(500-330)+3.94*(700-500)+4.6*(1000-700)+5.03*(degree-1000);
}else
{
cout<<"用電度數輸入錯誤!"<<endl;
system("pause");
goto re;
}
}else
{
cout<<"月份輸入錯誤!"<<endl;
system("pause");
goto re;
}
cout<<endl<<"您要繳交的電費共 "<<money<<"元!"<<endl;
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2