9: Tickets prices

9 ticket prices

Author: Turbo Time limit: 1S Section: branch structure

Problem Description:
A Tourist attractions ticket price is $ 5 per person. But the community can offer, divided into the following situation:
the number exceeds 20, the owner of 10% discount;
number of people over 40, the owner of a 15% discount;
number of people over 80, the owner of 20% discount;
number more than 120, the owner 30% discount.
Please follow according to the number of groups to determine the total ticket price of the group.

Input Description:
Enter an integer i (0≤i≤1,000), it represents the total number of a group. Beginning of the line end of the line and no extra spaces.

Description Output:
output a real number, i.e. the group total fare to be paid, accurate to one decimal place. Beginning of the line and the end of the line do not print extra spaces.

Entry:
80
Sample output:
340.00
Code:

#include <stdio.h>
int main()
{
    int n;
    while (scanf("%d", &n) != EOF)
    {
        if (n > 120)
        {
            printf("%.2f", (float)n * 5 * 0.7);
        }
        else if (n > 80)
        {
            printf("%.2f", (float)n * 5 * 0.8);
        }
        else if (n > 40)
        {
            printf("%.2f", (float)n * 5 * 0.85);
        }
        else if (n > 20)
        {
            printf("%.2f", (float)n * 5 * 0.9);
        }
        else
        {
            printf("%.2f", (float)n * 5 );
        }
    }
    return 0;
}

Guess you like

Origin www.cnblogs.com/VictorierJwr/p/12242188.html