描述:
某航空公司购票规定:在旅游旺季7月~9月,如果购票超过20(含20)张,优惠票价的15%,购票20张以下优惠票价的5%;在旅游淡季1月~4月、11月和12月,如果购票超过20(含20)张,优惠票价的30%,购票20张以下优惠票价的20%;其他情况一律优惠票价的10%。
输入采购机票月份、数量和单价,根据某航空公司购票优惠规定,编程计算并输出优惠后的机票总金额。
输入:
在一行中输入3个整数month(1≤month≤12)、number(1≤number≤1000)和price(1≤price≤1000000),分别表示月份、数量和单价,整数之间用空格隔开。
输出:
在第一行中按格式“The total price is ××”输出一个浮点数(保留小数点后1位),即优惠后的机票总金额。
输入样例 1:8 31 805
输出样例 1:The total price is 21211.8
输入样例 2:6 18 609
输出样例 2:The total price is 9865.8
#include <stdio.h>
int main(void)
{
double month, number, price;
double totalprice = 0.00;
scanf("%lf %lf %lf", &month, &number, &price);
if ( month>=7 && month<=9 ) {
if ( number>=20 ) {
totalprice = price*number*0.85;
} else {
totalprice = price*number*0.95;
}
} else if ( month==1 || month==2 || month==3 || month==4 || month==11 || month==12 ) {
if ( number>=20 ) {
totalprice = price*number*0.70;
} else {
totalprice = price*number*0.80;
}
} else {
totalprice = price*number*0.90;
}
printf("The total price is %.1f", totalprice);
return 0;
}