- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int m,d;
- float p;
- cout<<"***歡迎使用小米的電費計算機***"<<endl<<endl;
- cout<<"請輸入月份: ";
- cin>>m;
- cout<<"用電度數: ";
- cin>>d;
- if((m>=10 && m<=12) || (m>=1 && m<=5))
- {
- if(d>1000)
- p=120*2.1+(330-120)*2.68+(500-330)*3.61+(700-500)*4.48+(1000-700)*5.03+(d-1000)*5.28;
- else if(d>700 && d<=1000)
- p=120*2.1+(330-120)*2.68+(500-330)*3.61+(700-500)*4.48+(d-700)*5.03;
- else if(d>500 && d<=700)
- p=120*2.1+(330-120)*2.68+(500-330)*3.61+(d-500)*4.48;
- else if(d>330 && d<=500)
- p=120*2.1+(330-120)*2.68+(d-330)*3.61;
- else if(d>120 && d<=330)
- p=120*2.1+(d-120)*2.68;
- else
- p=d*2.1;
- }else
- {
- if(d>1000)
- p=120*2.1+(330-120)*3.02+(500-330)*4.39+(700-500)*5.44+(1000-700)*6.16+(d-1000)*6.71;
- else if(d>700 && d<=1000)
- p=120*2.1+(330-120)*3.02+(500-330)*4.39+(700-500)*5.44+(d-700)*6.16;
- else if(d>500 && d<=700)
- p=120*2.1+(330-120)*3.02+(500-330)*4.39+(d-500)*5.44;
- else if(d>330 && d<=500)
- p=120*2.1+(330-120)*3.02+(d-330)*4.39;
- else if(d>120 && d<=330)
- p=120*2.1+(d-120)*3.02;
- else
- p=d*2.1;
- }
- cout<<endl<<"您要繳交的電費共: "<<p<<"元!"<<endl;
- system("pause");
- return 0;
- }
複製代碼 |