Konix

Influence Calculator

Oct 10th, 2013
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.80 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class InfCalc
  4. {
  5.    public int endos;
  6.    public int updates;
  7.    public int currentSPDR;
  8.    public double SPDRatDate;
  9.    public int lowerTI;
  10.    public int higherTI;
  11.    public int i;
  12.    
  13.    public InfCalc(int currentSPDR, int endos, int updates)
  14.    {
  15.       this.currentSPDR = currentSPDR;
  16.       this.endos = endos;
  17.       this.updates = updates;
  18.       SPDRatDate = Math.sqrt(((endos +1) * updates) + (currentSPDR * currentSPDR));
  19.       lowerTI = (currentSPDR * currentSPDR);
  20.       higherTI = (((currentSPDR + 1) * (currentSPDR + 1)) - 1);
  21.       i = (int)SPDRatDate;
  22.    }
  23.    
  24.    public int getSPDR()
  25.    {
  26.       return i;
  27.    }
  28.    
  29.    public int getLowerTI()
  30.    {
  31.       return lowerTI;
  32.    }
  33.    
  34.    public int getHigherTI()
  35.    {
  36.       return higherTI;
  37.    }
  38.    
  39.    public static void main(String args[])
  40.    {
  41.       char run = 'y';
  42.       while(run == 'y'){
  43.       Scanner scan = new Scanner(System.in);
  44.       System.out.println("Enter your current SPDR.");
  45.       int currentSPDR = scan.nextInt();
  46.  
  47.       System.out.println("Enter your current number of endorsements.");
  48.       int endos = scan.nextInt();
  49.  
  50.       System.out.println("Enter the number of updates.");
  51.       int updates = scan.nextInt();
  52.      
  53.       InfCalc result = new InfCalc(currentSPDR, endos, updates);
  54.       System.out.println("In " + result.updates + " updates, your SPDR will be at least " + result.getSPDR());
  55.       System.out.print("Your current true influence range is between ");
  56.       System.out.println( + result.getLowerTI() + " and " + result.getHigherTI());
  57.      
  58.       Scanner input = new Scanner(System.in);
  59.       System.out.print("Would you like to do another calculation? ");
  60.       System.out.println("y/n");
  61.       run = input.nextLine().charAt(0);
  62.          
  63.       }
  64.    }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment