zzulioj 1034: Summer sale

Topic Description
Shopping mall summer promotion, shopping under 500 yuan, no discount; shopping over 500 yuan (inclusive), 5% off; shopping over 1,000 yuan (inclusive), 10% off; shopping over 3,000 yuan (inclusive), 15% off; shopping over 5,000 yuan (Inclusive) 20% off for the above. According to the consumption amount, determine the actual amount the user needs to pay.
Enter
Enter a real number to indicate the consumption amount.
Output
Output a real number, indicating the actual amount the user needs to spend, with two decimal places.
Sample input Copy
5100
Sample output Copy
4080.00

#include<stdio.h>
int main()
{
    
    
	float n;
	scanf("%f",&n);
	if(n<500)
	  printf("%.2f\n",n);
	  else if(n>=500&&n<1000)
	    printf("%.2f\n",n*0.95);
	    else if(n>=1000&&n<3000)
	      printf("%.2f\n",n*0.9);
	      else if(n>=3000&&n<5000)
	        printf("%.2f",n*0.85);
	        else
	          printf("%.2f",n*0.8);
	return 0;
}

Guess you like

Origin blog.csdn.net/m0_53024529/article/details/112846947