fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. System.out.println("Система расчёта штрафов");
  13.  
  14.  
  15. int carSpeed = 145;
  16.  
  17. System.out.println("Штраф :" + CalculateFine(carSpeed) + " рублей");
  18. }
  19.  
  20.  
  21. public static int CalculateFine( int carSpeed)
  22. {
  23. int fineFor20to40 = 500;
  24. int fineFor40to60 = 1000;
  25. int fineFor60to80 = 2000;
  26. int fineFor80andMore = 5000;
  27.  
  28. int townSpeed = 60;
  29.  
  30.  
  31. int overSpeed = carSpeed - townSpeed;
  32.  
  33.  
  34. if(overSpeed < 20) {
  35. return 0;
  36. }
  37. if(overSpeed >= 20 && overSpeed < 40) {
  38. return fineFor20to40;
  39. }
  40. if(overSpeed >= 40 && overSpeed < 60) {
  41. return fineFor40to60;
  42. }
  43. if(overSpeed >= 60 && overSpeed < 80) {
  44. return fineFor60to80;
  45. }
  46. else {
  47. return fineFor80andMore;
  48. }
  49. }
  50. }
Success #stdin #stdout 0.09s 39168KB
stdin
Standard input is empty
stdout
Система расчёта штрафов
Штраф :5000 рублей