Coding of file
-
Upload
rushin-mehta -
Category
Documents
-
view
214 -
download
2
description
Transcript of Coding of file
Q. 1. A) import java.util.*;class SavingsAccount{double annualInterestRate=0;private double savingsBalance = 0;SavingsAccount(double num){savingsBalance=num;}void calculateMonthlyInterest(){savingsBalance += (savingsBalance * annualInterestRate)/12;}void modifyInterestRate(double n){annualInterestRate=n;}void display(){System.out.println("New balance = " +savingsBalance);}}public class saving{public static void main(String[] args){SavingsAccount saver1= new SavingsAccount(2000);SavingsAccount saver2= new SavingsAccount(3000);saver1.modifyInterestRate(0.04);saver2.modifyInterestRate(0.04);saver1.calculateMonthlyInterest();saver2.calculateMonthlyInterest();System.out.println("Saver 1 :\n");saver1.display();System.out.println("Saver 2 :\n");saver2.display();saver1.modifyInterestRate(0.05);saver2.modifyInterestRate(0.05);saver1.calculateMonthlyInterest();saver2.calculateMonthlyInterest();System.out.println("Saver 1 :\n");saver1.display();System.out.println("Saver 2 :\n");saver2.display();}}