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("Penalty calculation system");
  13.  
  14. int carSpeed = 130;
  15.  
  16. int fineFrom20to40 = 500;
  17. int fineFrom40to60 = 1000;
  18. int fineFrom60to80 = 2000;
  19. int fineFrom80andMore = 5000;
  20.  
  21. int townSpeed = 60;
  22.  
  23. int overSpeed = carSpeed - townSpeed;
  24.  
  25. if(overSpeed < 20) {
  26. System.out.println("Speed is not exceeded or exceeded slightly");
  27. }
  28. else if(overSpeed >=20 && overSpeed < 40) {
  29. System.out.println("Fine: " + fineFrom20to40);
  30. }
  31. else if(overSpeed >=40 && overSpeed < 60) {
  32. System.out.println("Fine: " + fineFrom40to60);
  33. }
  34. else if(overSpeed >=60 && overSpeed < 80) {
  35. System.out.println("Fine: " + fineFrom60to80);
  36. }
  37. else if(overSpeed >=80) {
  38. System.out.println("Fine: " + fineFrom80andMore);
  39. }
  40. }
  41. }
Success #stdin #stdout 0.08s 49344KB
stdin
Standard input is empty
stdout
Penalty calculation system
Fine: 2000