- #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;
- }
複製代碼 |