JustPaste
HomeCategoriesAboutDonateContactTerms of UsePrivacy Policy
JustPaste

Free online notepad — write and share instantly

Navigate

  • Home
  • Timeline
  • Categories

Info

  • About
  • Donate
  • Contact

Legal

  • Terms of Use
  • Privacy Policy

© 2026 JustPaste.app. All rights reserved.

Made with ♥ by JustPaste

Untitled Page | JustPaste.app
21 days ago4 views
👨‍💻Programming
package labExer3;

import java.util.Scanner;

public class RunSavingsAccount {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);

        SavingsAccount savings = new SavingsAccount();

  
        System.out.print("Enter interest rate: ");
        double rate = input.nextDouble();

     
        SavingsAccount.setInterestRate(rate);

       
        System.out.print("Enter amount to deposit: ");
        double amount = input.nextDouble();

        savings.deposit(amount);

       
        SavingsAccount.showBalance(savings);

       
        System.out.print("Press D for another deposit or W for withdrawal: ");
        char choice = input.next().charAt(0);

        if (choice == 'D' || choice == 'd') {

            System.out.print("Enter amount to deposit: ");
            amount = input.nextDouble();

            savings.deposit(amount);

        } else if (choice == 'W' || choice == 'w') {

            System.out.print("Enter amount to withdraw: ");
            amount = input.nextDouble();

            savings.withdraw(amount);
        }


        SavingsAccount.showBalance(savings);


        if (savings.getBalance() > 1000) {

            savings.addInterest();

            System.out.println("Interest added.");
            SavingsAccount.showBalance(savings);
        }

        input.close();
    }
}
← Back to timeline