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