Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class SavingAccount{
- public static double annualInterestRate;
- private double savingsBalance;
- public double SavingsBalance{
- get {return savingsBalance;}
- set {savingsBalance = value;}
- }
- public void calculateMonthlyInterest(){
- double x = (savingsBalance * annualInterestRate * 1.0) / 12;
- savingsBalance += x;
- }
- public void modifyInterestRate(int newValue){
- annualInterestRate = newValue;
- }
- }
- class Program{
- public static void Main(){
- SavingAccount saver1 = new SavingAccount();
- SavingAccount saver2 = new SavingAccount();
- saver1.SavingsBalance = 2000.00;
- saver2.SavingsBalance = 3000.00;
- saver1.modifyInterestRate(3);
- saver1.calculateMonthlyInterest();
- saver2.calculateMonthlyInterest();
- Console.Write($"Saver1 - {saver1.SavingsBalance}, ");
- Console.Write($"Saver2 - {saver2.SavingsBalance}\n");
- saver1.modifyInterestRate(4);
- saver1.calculateMonthlyInterest();
- saver2.calculateMonthlyInterest();
- Console.WriteLine($"Next month: Saver1 - {saver1.SavingsBalance}, Saver2 - {saver2.SavingsBalance}");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement