Guest User

Untitled

a guest
Jan 5th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. //A simple program to calculate the amount of exp required to reach a specific level in MCMMO,
  2. //a Minecraft mod for multiplayer.
  3. import java.util.Scanner;
  4. public class mcmmoExp {
  5. public static void main(String[] args) {
  6. //Ask the user for the level they want.
  7. Scanner input = new Scanner(System.in);
  8. System.out.println("Calculate exp total for what level?");
  9. int expInput = input.nextInt();
  10. System.out.println(expTotal(expInput));
  11.  
  12. }
  13. //Calculates the total exp for the given level.
  14. public static int expTotal(int expInput){
  15. int expAcc = 0;
  16. int totalExp = 0;
  17. int currentLvl = 1;
  18. //Initializing some variables for calculation later.
  19. for (int i=1; i<=expInput; i++){
  20.  
  21. /*The amount of XP needed to reach the next level are calculated with this simple formula:
  22. * XPtoNextLevel = 1000 + (CurrentLevel * 20) For each level, this loop calculates out the
  23. * amount of exp needed to level and adds that to totalExp. totalExp is then returned from
  24. * the function and printed for the user to see. */
  25. expAcc = 1000 + (i*20);
  26. currentLvl = currentLvl + 1;
  27. totalExp = totalExp + expAcc;
  28. }
  29. return totalExp;
  30. }
  31.  
  32. }
Add Comment
Please, Sign In to add comment