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