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 = 114;
  15.  
  16. int fineFor20to40 = 500;
  17. int fineFor40to60 = 1000;
  18. int fineFor60to80 = 2000;
  19. int fineFor80andMore = 5000;
  20.  
  21. int townSpeed =90,countrySpeed = 90,overSpeed;
  22.  
  23. boolean isTown = true;
  24.  
  25. if (isTown)
  26. overSpeed = carSpeed - townSpeed;
  27. else overSpeed = carSpeed - countrySpeed;
  28.  
  29. if(overSpeed < 20) {
  30. System.out.println("Скорость не превышена или превышена незначительно");
  31. }
  32. else if(overSpeed >= 20 && overSpeed < 40) {
  33. System.out.println("Штраф: " + fineFor20to40);
  34. }
  35. else if(overSpeed >= 40 && overSpeed < 60) {
  36. System.out.println("Штраф: " + fineFor40to60);
  37. }
  38. else if(overSpeed >= 60 && overSpeed < 80) {
  39. System.out.println("Штраф: " + fineFor60to80);
  40. }
  41. else if(overSpeed >= 80) {
  42. System.out.println("Штраф: " + fineFor80andMore);
  43. }
  44. }
  45. }
Success #stdin #stdout 0.12s 47860KB
stdin
Standard input is empty
stdout
Система расчёта штрафов
Штраф: 500