Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //A simple program to calculate the amount of exp required to reach a specific level in MCMMO,
- //a Minecraft mod for multiplayer.
- import java.util.Scanner;
- public class mcmmoExp {
- public static void main(String[] args) {
- //Ask the user for the level they want.
- Scanner input = new Scanner(System.in);
- System.out.println("Calculate exp total for what level?");
- int expInput = input.nextInt();
- System.out.println(expTotal(expInput));
- }
- //Calculates the total exp for the given level.
- public static int expTotal(int expInput){
- int expAcc = 0;
- int totalExp = 0;
- int currentLvl = 1;
- //Initializing some variables for calculation later.
- for (int i=1; i<=expInput; i++){
- /*The amount of XP needed to reach the next level are calculated with this simple formula:
- * XPtoNextLevel = 1000 + (CurrentLevel * 20) For each level, this loop calculates out the
- * amount of exp needed to level and adds that to totalExp. totalExp is then returned from
- * the function and printed for the user to see. */
- expAcc = 1000 + (i*20);
- currentLvl = currentLvl + 1;
- totalExp = totalExp + expAcc;
- }
- return totalExp;
- }
- }
Add Comment
Please, Sign In to add comment