Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Task2 {
- public static void main(String[] args) {
- // loop that repeats 9 times
- for (int i = 0; i<9; i++) {
- // create scanner and profit class object
- Scanner input = new Scanner(System.in);
- YearlyProfit account = new YearlyProfit();
- // user input saved to class variables
- System.out.print("Enter starting amount: ");
- account.setStartingAmount(input.nextDouble());
- System.out.print("Enter interest rate in percent: ");
- account.setInterestRate(input.nextDouble());
- // calculate profit
- account.setProfit(account.getStartingAmount(), account.getInterestAmount());
- // print profit
- System.out.print("The yearly profit was: " + account.getProfit() + "\n\n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement