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. int carSpeed = 187;
  15.  
  16. System.out.println("Штраф " + calculateFine(carSpeed) + " рублей");
  17.  
  18.  
  19. }
  20. public static int calculateFine(int carSpeed)
  21. {
  22. int fineFor20to40 = 500;
  23. int fineFor40to60 = 1000;
  24. int fineFor60to80 = 2000;
  25. int fineFor80andMore = 5000;
  26.  
  27. int townSpeed = 60;
  28.  
  29. int overSpeed = carSpeed - townSpeed;
  30.  
  31. if(overSpeed < 20) {
  32. return 0;
  33. }
  34. if(overSpeed >= 20 && overSpeed < 40) {
  35. return fineFor20to40;
  36. }
  37. if(overSpeed >= 40 && overSpeed < 60) {
  38. return fineFor40to60;
  39. }
  40. if(overSpeed >= 60 && overSpeed < 80) {
  41. return fineFor60to80;
  42. }
  43. else {
  44. return fineFor80andMore;
  45. }
  46. }
  47. }
Success #stdin #stdout 0.13s 55396KB
stdin
Standard input is empty
stdout
Система расчёта штрафов
Штраф 5000 рублей