2055:【例3.5】收费(2055: [example 3.5] charging)

【题目描述】

乘坐飞机时,当乘客行李小于等于20公斤时,按每公斤1.68元收费,大于20公斤时,按每公斤1.98元收费,编程计算收费(保留2位小数)。

【输入】

行李重量。

【输出】

费用(保留2位小数)。

【输入样例】

20.00

【输出样例】

33.60
#include <bits/stdc++.h>
using namespace std;
int main(){
    double t,s=0; 
    cin>>t;
    if(t<=20){
        s=t*1.68;
    }
    else{
        s=t*1.98;
    }    
    printf("%.2f",s);
    return 0;
}
————————

[Title Description]

When taking the plane, when the passenger’s luggage is less than or equal to 20kg, it is charged at 1.68 yuan per kilogram. When it is greater than 20kg, it is charged at 1.98 yuan per kilogram, and the charge is calculated by programming (2 decimal places are reserved).

[input]

Baggage weight.

[output]

Fees (2 decimal places).

[input example]

20.00

[output example]

33.60
#include <bits/stdc++.h>
using namespace std;
int main(){
    double t,s=0; 
    cin>>t;
    if(t<=20){
        s=t*1.68;
    }
    else{
        s=t*1.98;
    }    
    printf("%.2f",s);
    return 0;
}