標題:
電費計算機(一)
[打印本頁]
作者:
陳品肇
時間:
2019-5-4 14:10
標題:
電費計算機(一)
參考台灣電力公司所公怖的
電費計算表格
, 設計一個計算電費的小工具,
讓使用者輸入月份, 與該月份的用電度數, 電腦回應該月份的電費.
[attach]6411[/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-5-4 15:13
本帖最後由 曲書辰 於 2019-5-4 15:16 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a,b;
float c;
re:
cout<<"請輸入月份:";
cin>>a;
cout<<"請輸入用電度:";
cin>>b;
if(a>=6 && a<=9)
{ if(b>=1 && b<=120)
{c=b*1.63;
}
else if(b>=121 && b<=330)
{c=120*1.63+(b-120)*2.38;
}
else if(b>=331 && b<=500)
{c=120*1.63+210*2.38+(b-120-210)*3.52;
}
else if(b>=501 && b<=700)
{c=120*1.63+210*2.38+230*3.52+(b-120-210-230)*4.8;
}
else if(b>=701 && b<=1000)
{c=120*1.63+210*2.38+230*3.52+200*4.8+(b-120-210-230-200)*5.66;
}
else
{c=120*1.63+210*2.38+230*3.52+200*4.8+300*5.66+(b-1000)*6.41;
}
goto end;
}
else if((a>=1 && a<=5)||(a>=10 && a<=12))
{ if(b>=1 && b<=120)
{c=b*1.63;
}
else if(b>=121 && b<=330)
{c=120*1.63+(b-120)*2.1;
}
else if(b>=331 && b<=500)
{c=120*1.63+210*2.10+(b-120-210)*2.89;
}
else if(b>=501 && b<=700)
{c=120*1.63+210*2.1+230*2.89+(b-120-210-230)*3.94;
}
else if(b>=701 && b<=1000)
{c=120*1.63+210*2.38+230*3.52+200*4.8+(b-120-210-230-200)*5.66;
}
else
{c=120*1.63+210*2.38+230*3.52+200*4.8+300*5.66+(b-1000)*6.41;
}
goto end;
}
else
{ cout<<"錯誤"<<endl;
system("pause");
goto re;
}
system("pause");
return 0;
}
作者:
王瑞喻
時間:
2019-5-4 15:13
本帖最後由 王瑞喻 於 2019-5-11 13:33 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
system("cls");
int month,d;
float sum=0;
cout<<"*****電費計算機*****"<<endl;
cout<<"請輸入月份: ";
cin>>month;
if(month>=6 && month<=9)
{
cout<<"用電度數: ";
cin>>d;
if(d>=0&&d<=120)
{
sum=d*1.63;
}else if(d>=120&&d<=330)
{
sum=120*1.63+(d-120)*2.38;
}else if(d>=330&&d<=500)
{
sum=120*1.63+210*2.38+(d-500)*3.52;
}else if(d>=500&&d<=700)
{
sum=120*1.63+210*2.38+170*3.52+(d-500)*4.80;
}else if(d>=700&&d<=1000)
{
sum=120*1.63+210*2.38+170*3.52+200*4.80+(d-700)*5.66;
}else if(d>=1000)
{
sum=120*1.63+210*2.38+170*3.52+200*4.80+300*5.66+(d-1000)*6.41;
}else
{
cout<<"用電度數輸入錯誤!"<<endl;
system("pause");
goto re;
}
}else if ((month>=1&&month<=5)||(month>=10&&month<=12))
{
cout<<"用電度數: ";
cin>>d;
if(d>=0&&d<=120)
{
sum=d*1.63;
}else if(d>=120&&d<=330)
{
sum=120*1.63+(d-120)*2.10;
}else if(d>=330&&d<=500)
{
sum=120*1.63+210*2.10+(d-500)*2.89;
}else if(d>=500&&d<=700)
{
sum=120*1.63+210*2.10+170*2.89+(d-500)*3.94;
}else if(d>=700&&d<=1000)
{
sum=120*1.63+210*2.10+170*2.89+200*3.94+(d-700)*4.60;
}else if(d>=1000)
{
sum=120*1.63+210*2.10+170*2.89+200*3.94+300*4.60+(d-1000)*5.03;
}else
{
cout<<"用電度數輸入錯誤!"<<endl;
system("pause");
goto re;
}
}else
{
cout<<"月份輸入錯誤!";
system("pause");
goto re;
}
cout<<"您要繳交的電費共"<<sum<<"元!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
洪寬瀧
時間:
2019-5-4 15:15
本帖最後由 洪寬瀧 於 2019-5-11 13:42 編輯
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-5-4 15:16
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
int degree,month;
float money;
cout<<"*** 電費計算機 ***"<<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");
}
}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") ;
}
cout<<endl<<"您要繳交的電費共 "<<money<<"元!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
吳孟修
時間:
2019-5-4 15:17
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
system("cls");
int month,p=0;
float sum;
cout<<"請輸入月份:";
cin>>month;
if(month>=6 && month<=9)
{
cout<<"請輸入用電度數:";
cin>>p;
if(p>=0 && p<=120)
{
sum=1.63*p;
}
else if(p>120 && p<=330)
{
sum=1.63*120+2.38*(p-120);
}
else if(p>330 && p<=500)
{
sum=1.63*120+2.38*(330-120)+3.52*(p-330);
}
else if(p>500 && p<=700)
{
sum=1.63*120+2.38*(330-120)+3.52*(500-330)+4.8*(p-500);
}
else if(p>700 && p<=1000)
{
sum=1.63*120+2.38*(330-120)+3.52*(500-330)+4.8*(700-500)+5.66*(p-700);
}
else if(p>1000)
{
sum=1.63*120+2.38*(330-120)+3.52*(500-330)+4.8*(700-500)+5.66*(1000-700)+6.41*(p-1000);
}
else
{
cout<<"輸入錯誤"<<endl;
system("pause");
goto re;
}
}
else if((month>=1 && month<=5)||(month>=10 && month<=12))
{
cout<<"請輸入用電度數:";
cin>>p;
if(p>=0 && p<=120)
{
sum=1.63*p;
}
else if(p>120 && p<=330)
{
sum=1.63*120+2.1*(p-120);
}
else if(p>330 && p<=500)
{
sum=1.63*120+2.1*(330-120)+2.89*(p-330);
}
else if(p>500 && p<=700)
{
sum=1.63*120+2.1*(330-120)+2.89*(500-330)+3.94*(p-500);
}
else if(p>700 && p<=1000)
{
sum=1.63*120+2.1*(330-120)+2.89*(500-330)+3.94*(700-500)+4.6*(p-700);
}
else if(p>1000)
{
sum=1.63*120+2.1*(330-120)+2.89*(500-330)+3.94*(700-500)+4.6*(1000-700)+5.03*(p-1000);
}
else
{
cout<<"輸入錯誤"<<endl;
system("pause");
goto re;
}
}
else
{
cout<<"月份輸入錯誤!"<<endl;
system("pause");
goto re;
}
cout<<endl<<"您要繳交的電費共 "<<sum<<"元!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
吳孟書
時間:
2019-5-4 15:18
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int d,month;
float money;
cout<<"*** 電費計算機 ***"<<endl<<endl;
re:
cout<<"請輸入月份:";
cin>>month;
if(month>=6 && month<=9)
{
rf:
cout<<"請輸入用電度數:";
cin>>d;
if(d>=1 && d<=120)
{
money=1.63*d;
}else if(d>=121 && d<=330)
{
money=1.63*120+2.38*(d-120);
}else if(d>330 && d<=500)
{
money=1.63*120+2.38*(330-120)+3.52*(d-330);
}else if(d>500 && d<=700)
{
money=1.63*120+2.38*(330-120)+3.52*(500-330)+4.8*(d-500);
}else if(d>700 && d<=1000)
{
money=1.63*120+2.38*(330-120)+3.52*(500-330)+4.8*(700-500)+5.66*(d-700);
}else if(d>=1001)
{
money=1.63*120+2.38*(330-120)+3.52*(500-330)+4.8*(700-500)+5.66*(1000-700)+6.41*(d-1000);
}else
{
cout<<"用電度數輸入錯誤!"<<endl;
system("pause");
goto rf;
}
}
else if((month>=1 && month<=5)||(month>=10 && month<=12))
{
rg:
cout<<"請輸入用電度數:";
cin>>d;
if(d>=1 && d<=120)
{
money=1.63*d;
}else if(d>=121 && d<=330)
{
money=1.63*120+2.10*(d-120);
}else if(d>330 && d<=500)
{
money=1.63*120+2.10*(330-120)+2.89*(d-330);
}else if(d>500 && d<=700)
{
money=1.63*120+2.10*(330-120)+2.89*(500-330)+3.94*(d-500);
}else if(d>700 && d<=1000)
{
money=1.63*120+2.10*(330-120)+2.89*(500-330)+3.94*(700-500)+4.6*(d-700);
}else if(d>=1001)
{
money=1.63*120+2.10*(330-120)+2.89*(500-330)+3.94*(700-500)+4.6*(1000-700)+5.03*(d-1000);
}else
{
cout<<"用電度數輸入錯誤!"<<endl;
system("pause");
goto rg;
}
}
else
{
cout<<"輸入錯誤"<<endl;
goto re;
}
cout<<"您要繳交的電費共"<<money<<"元!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
田宇任
時間:
2019-5-4 21:03
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
system("cls");
int du,month;
float money;
cout<<"請輸入月份: ";
cin>>month;
if(month>=6 && month<=9)
{
cout<<"用電度數: ";
cin>>du;
if(du>0 && du<=120)
{
money=du*1.63;
}else if(du>120 && du<=330)
{
money=1.63*120+2.38*(du-120);
}else if(du>330 && du<=500)
{
money=1.63*120+2.38*(330-120)+3.52*(du-330);
}else if(du>500 && du<=700)
{
money=1.63*120+2.38*(330-120)+3.52*(500-330)+4.8*(du-700);
}else if(du>700 && du<=1000)
{
money=1.63*120+2.38*(330-120)+3.52*(500-330)+4.8*(700-500)+5.66*(du-700);
}else if(du>=1001)
{
money=1.63*120+2.38*(330-120)+3.52*(500-330)+4.8*(700-500)+5.66*(1000-700)+6.41*(du-1000);
}else
{
cout<<"用電度數輸入錯誤!"<<endl;
system("pause");
goto re;
}
}else if((month>=10 && month<=12) || (month>=1 && month<=5))
{
cout<<"用電度數:"<<endl;
cin>>du;
if(du>0 && du<=120)
{
money=du*1.63;
}
else if(du>120 && du<=330)
{
money=1.63*120+2.10*(du-120);
}else if(du>330 && du<=500)
{
money=1.63*120+2.10*(330-120)+2.89*(du-330);
}
else if(du>500 && du<=700)
{
money=1.63*120+2.10*(330-120)+2.89*(500-330)+3.94*(du-700);
}
else if(du>700 && du<=1000)
{
money=1.63*120+2.10*(330-120)+2.89*(500-330)+3.94*(700-500)+4.60*(du-700);
}
else if(du>=1001)
{
money=1.63*120+2.10*(330-120)+2.89*(500-330)+3.94*(700-500)+4.60*(1000-700)+5.03*(du-1000);
}else
{
cout<<"用電度數輸入錯誤!"<<endl;
system("pause");
goto re;
}
}else
{
cout<<"月份輸入錯誤!"<<endl;
system("pause");
goto re;
}
cout<<"您要繳的電費為"<<money<<"元!"<<endl;
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2