China Railway stipulates that the mileage is priced in a tiered manner according to the mileage range

Source: Internet
Author: User

/* Algorithm: according to Chinese railway regulations, the mileage is priced in a tiered manner according to the mileage range.
* 1-km: 10 km for each section of 20 CIDR blocks,
*-Km: 20 km for each section of 10 CIDR blocks,
*-Km: 30 km for each section of 10 CIDR blocks,
* 70-1-km: 40 km for each section of 10 CIDR blocks,
*-Km: 50 km for each section of 10 blocks,
*-Km: 60 km for each section of the 10 section,
* 2-2-2900 km: 70 km for each section of Area 10,
* 2901-3700 km: 10 blocks, 80 km for each segment,
* 3701-4600 km: 90 km for each section of the 10 Section,
* 4600 kilometers or more, 100 kilometers per section.
* The mileage is calculated based on the shard section of each segment, and then summed.
*
* Progressive decrease:
* 1-200 km, with a progressive reduction rate of 0%.
* In the range of 10%-km, the delivery rate is.
* The descent rate is 20% in the range of-km.
* 30%-km, with a progressive reduction rate.
* The descent rate is 40% in the range of-km.
* The descent rate is 2500 in the range above 50% km.
*
* Calculate the discount rate of each section of the price range based on the discount rate of the area in which the price range is delivered, and then calculate the discount mileage for each section,
* This is the mileage that generates the fee and is used for calculating the next fare.
**/
Private Static int getfavourabletolldistance (INT km ){

// Determine the mileage range
If (km> 0 ){
If (km & gt; 200 ){
If (km & gt; 400 ){
If (km & gt; 700 ){
If (km & gt; 1100 ){
If (km & gt; 1600 ){
If (km & gt; 2200 ){
If (km & gt; 2900 ){
If (km & gt; 3700 ){
If (km & gt; 4600 ){
Km = (km-4600)/100 + 1) * 100 + 4600;
} Else {
Km = (km-3700)/90 + 1) * 90 + 3700;
}
} Else {
Km = (km-2900)/80 + 1) * 80 + 2900;
}
} Else {
Km = (km-2200)/70 + 1) * 70 + 2200;
}
} Else {
Km = (km-1600)/60 + 1) * 60 + 1600;
}
} Else {
Km = (km-1100)/50 + 1) * 50 + 1100;
}
} Else {
Km = (km-700)/40 + 1) * 40 + 700;
}
} Else {
Km = (km-400)/30 + 1) * 30 + 400;
}
} Else {
Km = (km-200)/20 + 1) * 20 + 200;
}
} Else {
Km = (km/10 + 1) * 10;
}
} Else {
Km = 0;
}
// Discount for descending order
If (km & gt; 2500 ){
Km = (INT) (km-2500) * 0.5 + 1000*0.6 + 500*0.7 + 500*0.8
+ 300*0.9 + 200*1 );
} Else {
If (km & gt; 1500 ){
Km = (INT) (km-1500) * 0.6 + 500*0.7 + 500*0.8 + 300
* 0.9 + 200*1 );
} Else {
If (km & gt; 1000 ){
Km = (INT) (km-1000) * 0.7 + 500*0.8 + 300*0.9 + 200*1 );
} Else {
If (km & gt; 500 ){
Km = (INT) (km-500) * 0.8 + 300*0.9 + 200*1 );
} Else {
If (km & gt; 200 ){
Km = (INT) (km-200) * 0.9 + 200*1 );
} Else {
If (km> 0 ){

} Else {
Km = 0;
}
}
}
}
}
}

Return km;
}

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.