返回列表 發帖
  1. #include<cstdlib>
  2. #include<iostream>
  3. using namespace std;
  4. int main()
  5. {

  6.    cout<<"***歡迎使用小米的電費計算機***"<<endl<<endl;
  7.    int month,d;
  8.    cout<<"請輸入月份: ";
  9.    cin>>month;
  10.    cout<<"用電度數: ";
  11.    cin>>d;
  12.    
  13.    // 金額總計
  14.    float total=0;
  15.    
  16.    // 非夏月條件  10~12 or 1~5
  17.    if((month>=10 && month<=12)||(month>=1 && month<=5))
  18.    {
  19.    }else
  20.    {
  21.         // 夏月
  22.         if(d<=120)
  23.         {
  24.            total = d*2.1;
  25.         }else if(d>=121 && d<=330)
  26.         {
  27.            total = 120*2.1 + (d-120)*3.02;
  28.         }else if(d>=331 && d<=500)
  29.         {
  30.            total = 120*2.1 + 210*3.02 + (d-330)*4.39;
  31.         }else if(d>=501 && d<=700)
  32.         {
  33.            total = 120*2.1+(330-120)*3.02+(500-330)*4.39+(d-500)*5.44;
  34.         }else if(d>=701 && d<=1000)
  35.         {
  36.            total = 120*2.1+(330-120)*3.02+(500-330)*4.39+(700-500)*5.44+(d-700)*6.16;
  37.         }else
  38.         {
  39.            total =120*2.1+(330-120)*3.02+(500-330)*4.39+(700-500)*5.44+(1000-700)*6.16+(d-1000)*6.71;
  40.         }
  41.    }
  42.    
  43.    cout<<"總計:"<<total<<endl;
  44.    system("pause");
  45.    return 0;
  46. }
複製代碼

TOP

返回列表