Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Task2 {
  3.  
  4. public static void main(String[] args) {
  5.  
  6. // loop that repeats 9 times
  7. for (int i = 0; i<9; i++) {
  8.  
  9. // create scanner and profit class object
  10. Scanner input = new Scanner(System.in);
  11. YearlyProfit account = new YearlyProfit();
  12.  
  13. // user input saved to class variables
  14. System.out.print("Enter starting amount: ");
  15. account.setStartingAmount(input.nextDouble());
  16. System.out.print("Enter interest rate in percent: ");
  17. account.setInterestRate(input.nextDouble());
  18.  
  19. // calculate profit
  20. account.setProfit(account.getStartingAmount(), account.getInterestAmount());
  21.  
  22. // print profit
  23. System.out.print("The yearly profit was: " + account.getProfit() + "\n\n");
  24.  
  25. }
  26.  
  27. }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement