標題:
電費計算機 (一)
[打印本頁]
作者:
tonyh
時間:
2021-3-20 19:34
標題:
電費計算機 (一)
本帖最後由 tonyh 於 2021-3-20 20:56 編輯
參考台灣電力公司所公怖的
電費計算表格
,設計一個計算電費的小工具,
讓使用者輸入月份,與該月份的用電度數,電腦回應該月份的電費。
單位: 元 / 每度
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int m,d; //month degree
float fee;
cout<<"***電費計算機***"<<endl<<endl;
cout<<"請輸入月份: ";
cin>>m;
cout<<"用電度數: ";
cin>>d;
if(m>=6 && m<=9)
{
if(d>=1001)
fee=120*2.1+210*3.02+170*4.39+200*5.44+300*6.16+(d-1000)*6.71;
else if(d>=701)
fee=120*2.1+210*3.02+170*4.39+200*5.44+(d-700)*6.16;
else if(d>=501)
fee=120*2.1+210*3.02+170*4.39+(d-500)*5.44;
else if(d>=331)
fee=120*2.1+210*3.02+(d-330)*4.39;
else if(d>=121)
fee=120*2.1+(d-120)*3.02;
else
fee=d*2.1;
}else
{
if(d>=1001)
fee=120*2.1+210*2.68+170*3.61+200*4.48+300*5.03+(d-1000)*5.28;
else if(d>=701)
fee=120*2.1+210*2.68+170*3.61+200*4.48+(d-700)*5.03;
else if(d>=501)
fee=120*2.1+210*2.68+170*3.61+(d-500)*4.48;
else if(d>=331)
fee=120*2.1+210*2.68+(d-330)*3.61;
else if(d>=121)
fee=120*2.1+(d-120)*2.68;
else
fee=d*2.1;
}
cout<<endl<<"您要繳的電費共: "<<fee<<" 元!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
朱奕祐
時間:
2021-3-20 20:05
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int m,d;
float p;
cout<<"※※※歡迎使用小朱的電費計算機※※※"<<endl<<endl;
cout<<"請輸入月份啦乾: ";
cin>>m;
cout<<"用電度數啦乾: ";
cin>>d;
if((m>=10 && m<=12) || (m>=1 && m<=5))
{
if(d>1000)
p=120*2.1+(330-120)*2.68+(500-330)*3.61+(700-500)*4.48+(1000-700)*5.03+(d-1000)*5.28;
else if(d>700 && d<=1000)
p=120*2.1+(330-120)*2.68+(500-330)*3.61+(700-500)*4.48+(d-700)*5.03;
else if(d>500 && d<=700)
p=120*2.1+(330-120)*2.68+(500-330)*3.61+(d-500)*4.48;
else if(d>330 && d<=500)
p=120*2.1+(330-120)*2.68+(d-330)*3.61;
else if(d>120 && d<=330)
p=120*2.1+(d-120)*2.68;
else
p=d*2.1;
}else
{
if(d>1000)
p=120*2.1+(330-120)*3.02+(500-330)*4.39+(700-500)*5.44+(1000-700)*6.16+(d-1000)*6.71;
else if(d>700 && d<=1000)
p=120*2.1+(330-120)*3.02+(500-330)*4.39+(700-500)*5.44+(d-700)*6.16;
else if(d>500 && d<=700)
p=120*2.1+(330-120)*3.02+(500-330)*4.39+(d-500)*5.44;
else if(d>330 && d<=500)
p=120*2.1+(330-120)*3.02+(d-330)*4.39;
else if(d>120 && d<=330)
p=120*2.1+(d-120)*3.02;
else
p=d*2.1;
}
cout<<endl<<"您要繳交的電費共: "<<p<<"元啦乾!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
許洧熏
時間:
2021-3-20 20:39
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int m,d;
float fee;
cout<<"電費計算機"<<endl<<endl;
cout<<"請輸入月份: ";
cin>>m;
cout<<"請輸入電度數: ";
cin>>d;
if((m>=10 && m<=12) || (m>=1 && m<=5))
{
if(d>1000)
fee=120*2.1+(330-120)*2.68+(500-330)*3.61+(700-500)*4.48+(1000-700)*5.03+(d-1000)*5.28;
else if(d>700 && d<=1000)
fee=120*2.1+(330-120)*2.68+(500-330)*3.61+(700-500)*4.48+(d-700)*5.03;
else if(d>500 && d<=700)
fee=120*2.1+(330-120)*2.68+(500-330)*3.61+(d-500)*4.48;
else if(d>330 && d<=500)
fee=120*2.1+(330-120)*2.68+(d-330)*3.61;
else if(d>120 && d<=330)
fee=120*2.1+(d-120)*2.68;
else
fee=d*2.1;
}else
{
if(d>1000)
fee=120*2.1+(330-120)*3.02+(500-330)*4.39+(700-500)*5.44+(1000-700)*6.16+(d-1000)*6.71;
else if(d>700 && d<=1000)
fee=120*2.1+(330-120)*3.02+(500-330)*4.39+(700-500)*5.44+(d-700)*6.16;
else if(d>500 && d<=700)
fee=120*2.1+(330-120)*3.02+(500-330)*4.39+(d-500)*5.44;
else if(d>330 && d<=500)
fee=120*2.1+(330-120)*3.02+(d-330)*4.39;
else if(d>120 && d<=330)
fee=120*2.1+(d-120)*3.02;
else
fee=d*2.1;
}
cout<<endl<<"您要繳交的電費共: "<<fee<<"元!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
呂尚霖
時間:
2021-3-20 20:46
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int m,d;
float feee;
cout<<"+++歡迎使用藍莓的電費計算機+++"<<endl<<endl;
cout<<"請輸入月份 : ";
cin>>m;
cout<<"用電度數 : ";
cin>>d;
if((m>=10 && m<=12) || (m>=1 && m<=5))
{
if(d>1000)
feee=120*2.1+(330-120)*2.68+(500-330)*3.61+(700-500)*4.48+(1000-700)*5.03+(d-1000)*5.28;
else if(d>700 && d<=1000)
feee=120*2.1+(330-120)*2.68+(500-330)*3.61+(700-500)*4.48+(d-700)*5.03;
else if(d>500 && d<=700)
feee=120*2.1+(330-120)*2.68+(500-330)*3.61+(d-500)*4.48;
else if(d>330 && d<=500)
feee=120*2.1+(330-120)*2.68+(d-330)*3.61;
else if(d>120 && d<=330)
feee=120*2.1+(d-120)*2.68;
else
feee=d*2.1;
}else
{
if(d>1000)
feee=120*2.1+(330-120)*3.02+(500-330)*4.39+(700-500)*5.44+(1000-700)*6.16+(d-1000)*6.71;
else if(d>700 && d<=1000)
feee=120*2.1+(330-120)*3.02+(500-330)*4.39+(700-500)*5.44+(d-700)*6.16;
else if(d>500 && d<=700)
feee=120*2.1+(330-120)*3.02+(500-330)*4.39+(d-500)*5.44;
else if(d>330 && d<=500)
feee=120*2.1+(330-120)*3.02+(d-330)*4.39;
else if(d>120 && d<=330)
feee=120*2.1+(d-120)*3.02;
else
feee=d*2.1;
}
cout<<endl<<"您要繳交的電費共是 : "<<feee<<"元ㄚㄚㄚㄚㄚㄚㄚㄚㄚ!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
俞成章
時間:
2021-3-20 20:57
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int m,d; //month degree
float fee;
cout<<"***電費計算機***"<<endl<<endl;
cout<<"請輸入月份: ";
cin>>m;
cout<<"用電度數: ";
cin>>d;
if(m>=6 && m<=9)
{
if(d>=1001)
fee=120*2.1+210*3.02+170*4.39+200*5.44+300*6.16+(d-1000)*6.71;
else if(d>=701)
fee=120*2.1+210*3.02+170*4.39+200*5.44+(d-700)*6.16;
else if(d>=501)
fee=120*2.1+210*3.02+170*4.39+(d-500)*5.44;
else if(d>=331)
fee=120*2.1+210*3.02+(d-330)*4.39;
else if(d>=121)
fee=120*2.1+(d-120)*3.02;
else
fee=d*2.1;
}else
{
if(d>=1001)
fee=120*2.1+210*2.68+170*3.61+200*4.48+300*5.03+(d-1000)*5.28;
else if(d>=701)
fee=120*2.1+210*2.68+170*3.61+200*4.48+(d-700)*5.03;
else if(d>=501)
fee=120*2.1+210*2.68+170*3.61+(d-500)*4.48;
else if(d>=331)
fee=120*2.1+210*2.68+(d-330)*3.61;
else if(d>=121)
fee=120*2.1+(d-120)*2.68;
else
fee=d*2.1;
}
cout<<endl<<"您要繳的電費共: "<<fee<<" 元!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
黃子倢
時間:
2021-3-20 20:58
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int m,d;
float fee;
cout<<"電費計算機"<<endl;
cout<<"請輸入月份";
cin>>m;
cout<<"用電度數";
cin>>d;
if(m>=6 && m<=9)
{
if(d>1001)
{
fee=120*2.1+(300-120)*3.02+(500-330)*4.39+(700-500)*5.44+(1000-700)*6.16+(d-1000)*6.71;
}else if(d>=701)
{
fee=120*2.1+(300-120)*3.02+(500-330)*4.39+(700-500)*5.44+(d-700)*6.16;
}else if(d>501)
{
fee=120*2.1+(300-120)*3.02+(500-330)*4.39+(d-500)*5.44;
}else if(d>331)
{
fee=120*2.1+(300-120)*3.02+(d-330)*4.39;
}else if(d>121)
{
fee=120*2.1+(d-121)*3.02;
}else
{
fee=d*2.1;
}
}
else
{
if(d>1001)
{
fee=120*2.1+(300-120)*2.68+(500-330)*3.61+(700-500)*4.48+(1000-700)*5.03+(d-1000)*5.28;
}else if(d>=701)
{
fee=120*2.1+(300-120)*2.68+(500-330)*3.61+(700-500)*4.48+(d-700)*5.03;
}else if(d>501)
{
fee=120*2.1+(300-120)*2.68+(500-330)*3.61+(d-500)*4.48;
}else if(d>331)
{
fee=120*2.1+(300-120)*2.68+(d-330)*3.61;
}else if(d>121)
{
fee=120*2.1+(d-121)*2.68;
}else
{
fee=d*2.1;
}
cout<<"總共"<<fee<<"元";
}
system("pause");
return 0;
}
複製代碼
作者:
王宇崴
時間:
2021-3-20 20:58
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int m,d;
float p;
cout<<"***電費計算機***"<<endl<<endl;
cout<<"請輸入月份: ";
cin>>m;
cout<<"用電度數: ";
cin>>d;
if((m>=10 && m<=12) || (m>=1 && m<=5))
{
if(d>1000)
p=120*2.1+(330-120)*2.68+(500-330)*3.61+(700-500)*4.48+(1000-700)*5.03+(d-1000)*5.28;
else if(d>700 && d<=1000)
p=120*2.1+(330-120)*2.68+(500-330)*3.61+(700-500)*4.48+(d-700)*5.03;
else if(d>500 && d<=700)
p=120*2.1+(330-120)*2.68+(500-330)*3.61+(d-500)*4.48;
else if(d>330 && d<=500)
p=120*2.1+(330-120)*2.68+(d-330)*3.61;
else if(d>120 && d<=330)
p=120*2.1+(d-120)*2.68;
else
p=d*2.1;
}else
{
if(d>1000)
p=120*2.1+(330-120)*3.02+(500-330)*4.39+(700-500)*5.44+(1000-700)*6.16+(d-1000)*6.71;
else if(d>700 && d<=1000)
p=120*2.1+(330-120)*3.02+(500-330)*4.39+(700-500)*5.44+(d-700)*6.16;
else if(d>500 && d<=700)
p=120*2.1+(330-120)*3.02+(500-330)*4.39+(d-500)*5.44;
else if(d>330 && d<=500)
p=120*2.1+(330-120)*3.02+(d-330)*4.39;
else if(d>120 && d<=330)
p=120*2.1+(d-120)*3.02;
else
p=d*2.1;
}
cout<<endl<<"您要繳交的電費共: "<<p<<"元啦!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
林鼎傑
時間:
2021-3-20 21:00
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int m,d;
float fee;
cout<<"*****歡迎使用超廢的電費計算機*****"<<endl<<endl;
cout<<"請輸入月份: ";
cin>>m;
cout<<"請輸入用電度數: ";
cin>>d;
if(m>=6 && m<=9)
{
if(d>=1001)
fee=120*2.1+(330-120)*3.02+(500-330)*4.39+(700-500)*5.44+(1000-700)*6.16+(d-1000)*6.71;
if(d>=701 && d<=1000)
fee=120*2.1+(330-120)*3.02+(500-330)*4.39+(700-500)*5.44+(d-700)*6.16;
if(d>=501 && d<=700)
fee=120*2.1+(330-120)*3.02+(500-330)*4.39+(d-500)*5.44;
if(d>=331 && d<=500)
fee=120*2.1+(330-120)*3.02+(d-330)*4.39;
if(d>=121 && d<=330)
fee=120*2.1+(d-120)*3.02;
if(d<=120)
fee=d*2.1;
}else
{
if(d>=1001)
fee=120*2.1+(330-120)*2.68+(500-330)*3.61+(700-500)*4.48+(1000-700)*5.03+(d-1000)*5.28;
if(d>=701 && d<=1000)
fee=120*2.1+(330-120)*2.68+(500-330)*3.61+(700-500)*4.48+(d-700)*5.03;
if(d>=501 && d<=700)
fee=120*2.1+(330-120)*2.68+(500-330)*3.61+(d-500)*4.48;
if(d>=331 && d<=500)
fee=120*2.1+(330-120)*2.68+(d-330)*3.61;
if(d>=121 && d<=330)
fee=120*2.1+(d-120)*2.68;
if(d<=120)
fee=d*2.1;
}
cout<<"你要繳交的電費共: "<<fee<<"元!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
余柏緯
時間:
2021-3-20 21:05
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int mon=0,e=0;
float fee=0;
cout<<"歡迎使用電費計算機"<<endl<<endl;
cout<<"請輸入月份:";
cin>>mon;
cout<<"用電度數:";
cin>>e;
if(mon>=6 && mon<=9)
{
if(e>=1001)
{
fee=120*2.1+(330-120)*3.02+(500-330)*4.39+(700-500)*5.44+(1000-700)*6.16+(e-1001)*6.71;
}else if(e>=701)
{
fee=120*2.1+(330-120)*3.02+(500-330)*4.39+(700-500)*5.44+(1000-e)*6.16;
}else if(e>=501)
{
fee=120*2.1+(330-120)*3.02+(500-330)*4.39+(700-e)*5.44;
}else if(e>=331)
{
fee=120*2.1+(330-120)*3.02+(500-e)*4.39;
}else if(e>=121)
{
fee=120*2.1+(330-e)*3.02;
}else
{
fee=e*2.1;
}
}else
{
if(e>=1001)
{
fee=120*2.1+(330-120)*2.68+(500-330)*3.61+(700-500)*4.48+(1000-700)*5.03+(e-1001)*5.28;
}else if(e>=701)
{
fee=120*2.1+(330-120)*2.68+(500-330)*3.61+(700-500)*4.48+(1000-e)*5.03;
}else if(e>=501)
{
fee=120*2.1+(330-120)*2.68+(500-330)*3.61+(700-e)*4.48;
}else if(e>=331)
{
fee=120*2.1+(330-120)*2.68+(500-e)*3.61;
}else if(e>=121)
{
fee=120*2.1+(330-e)*2.68;
}else
{
fee=e*2.1;
}
}
cout<<"您要繳的電費共:"<<fee<<"元!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
王秉鈞
時間:
2021-3-20 21:05
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int m,d;
cout<<"電子計算機"<<endl<<endl;
cout<<"請輸入月份";
cin>>m;
cout<<"用電度數";
cin>>d;
if(m>=6 && m<=9)
{
if(d>=1001)
fee=120*2.1+210*3.02+170*4.39+200*5.44+300*6.16+(d-1000)*6.71;
else if(d>=701)
fee=120*2.1+210*3.02+170*4.39+200*5.44+(d-700)*6.16;
else if(d>=501)
fee=120*2.1+210*3.02+170*4.39+(d-500)*5.44;
else if(d>=331)
fee=120*2.1+210*3.02+(d-330)*4.39;
else if(d>=121)
fee=120*2.1+(d-120)*3.02;
else
fee=d*2.1;
}else
{
if(d>=1001)
fee=120*2.1+210*2.68+170*3.61+200*4.48+300*5.03+(d-1000)*5.28;
else if(d>=701)
fee=120*2.1+210*2.68+170*3.61+200*4.48+(d-700)*5.03;
else if(d>=501)
fee=120*2.1+210*2.68+170*3.61+(d-500)*4.48;
else if(d>=331)
fee=120*2.1+210*2.68+(d-330)*3.61;
else if(d>=121)
fee=120*2.1+(d-120)*2.68;
else
fee=d*2.1;
}
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2