- #include <iostream>
- #include<iomanip>
- using namespace std;
- int main() {
- // Problem 1. 計算電費
- int N;
- cin >> N;
- double ele;
- for(int i = 0;i < N;i++)
- {
- double sum = 0, nsum = 0;
- cin >> ele;
- if(ele <= 120)
- {
- sum = ele*2.1;
- nsum = ele*2.1;
- }else if(120 < ele && ele <= 330)
- {
- sum = 120*2.1 + (ele-120)*3.02;
- nsum = 120*2.1 + (ele-120)*2.68;
- }else if(330 < ele && ele <= 500)
- {
- sum = 120*2.1 + 210*3.02 + (ele-330)*4.39;
- nsum = 120*2.1 + 210*2.68 + (ele-330)*3.61;
- }else if(500 < ele && ele <= 700)
- {
- sum = 120*2.1 + 210*3.02 + 170*4.39 + (ele-500)*4.97;
- nsum = 120*2.1 + 210*2.68 + 170*3.61 + (ele-500)*4.01;
- }else if(ele > 700)
- {
- sum = 120*2.1 + 210*3.02 + 170*4.39 + 200*4.97 + (ele-700)*5.63;
- nsum = 120*2.1 + 210*2.68 + 170*3.61 + 200*4.01 + (ele-700)*4.5;
- }
- cout << "Summer months:" << fixed << setprecision(2) << sum << endl;
- cout << "Non-Summer months:" << fixed << setprecision(2) << nsum << endl;
- }
- return 0;
- }
2018年1月12日 星期五
[ITSA Exam.61] Problem 1. 計算電費
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言