fork(1) 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("Штраф: " + calculatfine(carSpeed) + " рублей");
  17. }
  18.  
  19. public static int calculatfine(int carSpeed)
  20. {
  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.  
  35. if(overSpeed >= 20 && overSpeed < 40) {
  36. return fineFor20to40;
  37. }
  38.  
  39. if(overSpeed >= 40 && overSpeed < 60) {
  40. return fineFor40to60;
  41. }
  42.  
  43. if(overSpeed >= 60 && overSpeed < 80) {
  44. return fineFor60to80;
  45. }
  46. else {
  47. return fineFor80andMore;
  48. }
  49. }
  50. }
  51.  
  52.  
  53.  
Success #stdin #stdout 0.11s 55516KB
stdin
Standard input is empty
stdout
Система расчёта штрафов
Штраф: 5000 рублей