- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int a, b, c, d;
- cout<<"***愛地球電費計算機***"<<endl<<endl;
- cout<<"請輸入月份: ";
- cin>>a;
- switch(a)
- {
-
- case 6:
- case 7:
- case 8:
- case 9:
- cout<<"用電度數: ";
- cin>>b;
- if(b>=0 && b<=120)
- {
- d=b*2.1;
- }
- if(b>=121 && b<=330)
- {
- d=120*2.1+(b-120)*3.02;
- }
- if(b>=331 && b<=500)
- {
- d=120*2.1+210*3.02+(b-330)*4.39;
- }
- if(b>=501 && b<=700)
- {
- d=120*2.1+210*3.02+170*4.39+(b-500)*4.97;
- }
- if(b>700)
- {
- d=120*2.1+210*3.02+170*4.39+200*4.97+(b-700)*5.63;
- }
- break;
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 10:
- case 11:
- case 12:
- cout<<"用電度數: ";
- cin>>b;
- if(b>=0 && b<=120)
- {
- d=b*2.1;
- }
- if(b>=121 && b<=330)
- {
- d=120*2.1+(b-120)*2.68;
- }
- if(b>=331 && b<=500)
- {
- d=120*2.1+210*2.68+(b-330)*3.61;
- }
- if(b>=501 && b<=700)
- {
- d=120*2.1+210*2.68+170*3.61+(b-500)*4.01;
- }
- if(b>700)
- {
- d=120*2.1+210*2.68+170*3.61+200*4.01+(b-700)*4.5;
- }
- cout<<"您要繳交的電費共: "<<d<<"元"<<endl;
- break;
- default:
- cout<<"輸入錯誤";
- }
- system("pause");
- return 0;
- }
複製代碼 |