1-4-14: Calculate postage

Source: Internet
Author: User

Describe

The postage is calculated based on the weight of the message and whether the user chooses expedited. Calculation rule: Weight within 1000 grams (including 1000 grams), the basic fee of 8 yuan. More than 1000 grams of the portion, each 500 grams of extra charge of 4 yuan, less than 500 grams of the portion of 500 grams calculation; If the user chooses expedited, more than 5 yuan.

Enter an input line that contains an integer and a character separated by a space, indicating the weight (in grams) and whether it is expedited. If the character is Y, the description selects expedited, and if the character is n, the description is not expedited. An output line that contains an integer representing the postage. Sample input

X y

Sample output

17
1#include <stdio.h>2 intMain ()3 {4     inth,f=0;5     CharZ;6scanf"%d%c",&h,&z);7h=h- +; f=8;8      while(h>0)9     {Tenh-= -; f+=4; One     } A     if(z=='y') f+=5; -printf"%d\n", f); -     return 0; the}

1-4-14: Calculate postage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.