Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Calculator
- {
- public char hp;
- public int finalStat;
- public double natureMult;
- public void readInput()
- {
- Scanner keys = new Scanner(System.in);
- System.out.println("Enter the base stat.");
- int base = keys.nextInt();
- System.out.println("Enter the IV.");
- int iv = keys.nextInt();
- System.out.println("Enter the EV.");
- int ev = keys.nextInt();
- System.out.println("Enter the level.");
- int level = keys.nextInt();
- if(level<1 || level>100)
- {
- System.out.println("Error! Invalid level!");
- System.exit(0);
- }
- System.out.println("Is the nature increase, decrease, or neutral?");
- char nature;
- nature = keys.nextLine().toLowerCase().charAt(0);
- if(nature=='i')
- natureMult=1.1;
- else if(nature=='n')
- natureMult=1.0;
- else if(nature=='d')
- natureMult=0.9;
- else
- {
- System.out.println("Error! You entered an invalid multiplier!");
- System.exit(0);
- }
- System.out.println("Is the stat HP?");
- hp = keys.nextLine().toLowerCase().charAt(0);
- if(hp!='y' || hp!='n')
- {
- System.out.println("Error! You did not pick yes or no!");
- System.exit(0);
- }
- if(hp=='y')
- finalStat = hpCalc(base, iv, ev, level);
- else
- finalStat = statCalc(base, iv, ev, level, natureMult);
- }
- public void writeOutput()
- {
- if(hp=='y')
- System.out.println("The final stat is: " + finalStat);
- else if(hp=='n')
- System.out.println("The final stat is: " + finalStat);
- }
- private int hpCalc(int a, int b, int c, int d)
- {
- int stat;
- stat = (int)((b+2*a+c/4.0+100)*d/100+10);
- return stat;
- }
- private int statCalc(int e, int f, int g, int h, double i)
- {
- int stat;
- stat = (int)(((f+2*e+g/4.0)*g/100+5)*h);
- return stat;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement