- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int m, b, c, d;
- cout<<"@@@@電費計算機####"<<endl<<endl;
- cout<<"輸入月份: ";
- cin>>m;
- if(m>=6 && m<=9)
- {
- cout<<"用電度數: ";
- cin>>b;
- if(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;
- }
- cout<<"您的電費總共: "<<d<<"元"<<endl;
- }
- else if((m>=10 && m<=12) || (m>=1 && m<=5))
- {
- cout<<"用電度數: ";
- cin>>b;
- if(b<=120)
- {
- c=b*2.1;
- }
- if(b>=121 && b<=330)
- {
- c=120*2.1+(b-120)*2.68;
- }
- if(b>=331 && b<=500)
- {
- c=120*2.1+210*2.68+(b-330)*3.61;
- }
- if(b>=501 && b<=700)
- {
- c=120*2.1+210*2.68+170*3.61+(b-500)*4.01;
- }
- if(b>700)
- {
- c=120*2.1+210*2.68+170*3.61+200*4.01+(b-700)*4.5;
- }
- cout<<"您的電費共: "<<c<<"元"<<endl;
-
- }
- system("pause");
- return 0;
- }
複製代碼 |