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. int position=calculateHighScorePosition(1500);
  13. displayHighScorePosition("Stone",position);
  14. position=calculateHighScorePosition(900);
  15. displayHighScorePosition("shawn",position);
  16. position=calculateHighScorePosition(400);
  17. displayHighScorePosition("Simon",position);
  18. position=calculateHighScorePosition(50);
  19. displayHighScorePosition("sks",position);
  20.  
  21. displayHighScorePosition("at 1000", calculateHighScorePosition(1000));
  22. displayHighScorePosition("at 999", calculateHighScorePosition(999));
  23. displayHighScorePosition("at 501", calculateHighScorePosition(501));
  24.  
  25. displayHighScorePosition("at 500", calculateHighScorePosition(500));
  26. displayHighScorePosition("at 499", calculateHighScorePosition(499));
  27.  
  28.  
  29. displayHighScorePosition("at 100", calculateHighScorePosition(100));
  30. displayHighScorePosition("at 99", calculateHighScorePosition(99));
  31. }
  32.  
  33. public static void displayHighScorePosition(String playerName, int position) {
  34. // System.out.printf("%s managed to get into position %d on the high score table\n",
  35. // playerName, position);
  36. System.out.println(playerName + " managed to get into position");
  37. System.out.println(position + " on the high score table");
  38. }
  39.  
  40. public static int calculateHighScorePosition(int playerScore) {
  41. if(playerScore >= 1000){
  42. return 1;
  43. }else if(playerScore >= 500) {
  44. return 2;
  45. }else if(playerScore >= 100) {
  46. return 3;
  47. }else {
  48. return 4;
  49. }
  50. }
  51. }
Success #stdin #stdout 0.05s 2184192KB
stdin
Standard input is empty
stdout
Stone managed to get into position
1 on the high score table
shawn managed to get into position
2 on the high score table
Simon managed to get into position
3 on the high score table
sks managed to get into position
4 on the high score table
at 1000 managed to get into position
1 on the high score table
at 999 managed to get into position
2 on the high score table
at 501 managed to get into position
2 on the high score table
at 500 managed to get into position
2 on the high score table
at 499 managed to get into position
3 on the high score table
at 100 managed to get into position
3 on the high score table
at 99 managed to get into position
4 on the high score table