fork download
  1.  
  2. /**
  3.  *
  4.  * @author Damien Bell <SkyeShatter@gmail.com>
  5.  */
  6. import java.util.Scanner;
  7. class Jtutorial1 {
  8. public static void main(String args[]){
  9. Scanner input = new Scanner(System.in);
  10.  
  11. //Asks a user for how much money they want to invest in a bank
  12. //What is the APR of that bank. Annual percentage rate.
  13. //How long do you want to invest the money for.
  14. //i = p*r*t. interest = principle (starting investment)*(rate)*(time--in years)
  15.  
  16. System.out.println("How much money are you interested in investing: ");
  17. double principle = input.nextDouble();
  18.  
  19. System.out.println("\nWhat is the APR offered at this bank? (5.9% = 5.9): ");
  20. double rate = input.nextDouble();
  21. //rate = rate /100;
  22. rate /= 100; //Same as above.
  23.  
  24. System.out.println("\nHow long do you want to invest this money for? ");
  25. int Time = input.nextInt();
  26.  
  27. double total = principle * (1+rate*Time);
  28.  
  29. // System.out.println("\nThe total amount of money in the account after: " + Time + " years is: " + total); // Same as below but without using total variable.
  30. System.out.println("\nThe total amount of money in the account after: " + Time + " years is: " + (principle * (1+rate*Time)));
  31.  
  32.  
  33.  
  34.  
  35.  
  36. } //End main
  37. } //End class
  38.  
Success #stdin #stdout 0.08s 213440KB
stdin
25000
10
3
stdout
How much money are you interested in investing: 

What is the APR offered at this bank? (5.9% = 5.9):  

How long do you want to invest this money for? 

The total amount of money in the account after: 3 years is: 32500.0