/* package whatever; // don't place package name! */
import java.util.* ;
import java.lang.* ;
import java.io.* ;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
System .
out .
println ( "Система расчёта штрафов" ) ;
check( 60 , 0 ) ;
check( 90 , 500 ) ;
check( 110 , 1000 ) ;
check( 130 , 2000 ) ;
check( 150 , 5000 ) ;
}
public static void check( int carSpeed, int fine)
{
if ( calculateFine( carSpeed) != fine) {
System .
out .
println ( "Неверный штраф " + fine
+ " для скорости " + carSpeed
) ; }
else {
System .
out .
println ( "Штраф " + fine
+ " для скорости " + carSpeed
+ " рассчитан верно" ) ; }
}
public static int calculateFine( int carSpeed)
{
int fineFor20to40 = 500 ;
int fineFor40to60 = 1000 ;
int fineFor60to80 = 2000 ;
int fineFor80andMore = 5000 ;
int townSpeed = 60 ;
int overSpeed = carSpeed - townSpeed;
if ( overSpeed < 20 ) {
return 0 ;
}
if ( overSpeed >= 20 && overSpeed < 40 ) {
return fineFor20to40;
}
if ( overSpeed >= 40 && overSpeed < 60 ) {
return fineFor40to60;
}
if ( overSpeed >= 60 && overSpeed < 80 ) {
return fineFor60to80;
}
return fineFor80andMore;
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCVN5c3RlbS5vdXQucHJpbnRsbigi0KHQuNGB0YLQtdC80LAg0YDQsNGB0YfRkdGC0LAg0YjRgtGA0LDRhNC+0LIiKT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