To promote residents to conserve electricity, power companies performing province "price ladder", a mounting table of a residential user tariff is divided into two "step": Within months consumption 50 kwh (50 kWh) of price is 0.53 yuan / kWh; over 50 kwh, the excess portion of the electricity price increase 0.05 yuan / kWh. Write a program to calculate electricity.
Input formats:
Gives a user input in line with monthly consumption (unit: kWh).
Output formats:
Output line of the user tariff payable (RMB), the results of two decimals, formats such as: "cost = cope tariff value"; if power consumption is less than 0, then output "Invalid Value!".
Sample Input 1:
10
Output Sample 1:
cost = 5.30
Sample Input 2:
100
Output Sample 2:
cost = 55.50
#include<stdio.h> int main(void) { float a,Sum; scanf("%f",&a); if(a<0) printf("Invalid Value!"); else if(a>=0&&a<=50){ Sum=0.53*a; printf("cost = %.2f",Sum); } else{ Sum=0.53*50+(0.53+0.05)*(a-50); printf("cost = %.2f",Sum); } return 0; }