Postage is calculated based on the weight of the mail and whether the user chooses expedited. Calculation rules: If the weight is within 1000 grams (including 1000 grams), the basic fee is 8 yuan. For the part that exceeds 1000 grams, an overweight fee of 4 yuan will be charged for every 500 grams, and the part less than 500 grams will be calculated as 500 grams; if the user chooses to rush, an extra 5 yuan will be charged.
Input
Enter a line containing an integer and a character, separated by a space, indicating the weight (in grams) and whether it is expedited. If the character is y, it means rush is selected; if the character is n, it means no rush.
Output
Output a line containing an integer representing postage.
Example input
1200 y
Sample output
17
import java.util.Scanner;
import java.io.*;
public class Main {
public static void main(String[] args) {
int a,sum=0;
String s;
Scanner scan=new Scanner(System.in);
a=scan.nextInt();
s=scan.nextLine();
if(s.equals(" y"))
{
if(a<=1000)
sum=13;
else if(a>1000)
sum=((a-1000)/500+1)*4+8+5;
}
else
{
if(a<=1000)
{
sum=8;
}
else
{
sum=((a-1000)/500+1)*4+8;
}
}
System.out.println(sum);
scan.close();
}
}