Computer Science, asked by amarnath4173, 2 months ago

write a c++ program that Suppose you deposit Rs. 1 into an account this month, Rs. 2 into the account the second month, Rs. 4 the third month and so on, doubling your deposit each month. Write a program that displays the first month that your deposit exceeds Rs. 1,000,000.​

Answers

Answered by harsh2012s
0

Explanation:

My code is complete. It runs properly and produces the correct output. I did calculations by hand to check and then ran the program and it gives me the same result. I just want a second opinion. Are there ways for my code to be more efficient? Are there small details that I need to change? My professor marked me off for tiny errors, so I want to cover all the bases. I included the instructions down below just in case.

Design a SavingsAccount class that stores a savings account's balance, annual interest rate. The class constructor should accept the amount of savings account's starting balance and annual interest rate. The class should also have methods for subtracting the amount of a withdrawal, adding the amount of a deposit, and adding the amount of monthly interest to the balance. The monthly interest rate is the annual interest rate divided by 12. To add the monthly interest to the balance, multiply the monthly interest rate by the balance and add the amount to the balance. The class should also has mutator and accessor methods for each data field.

Then write a test program that calculate the balance of a savings account at the end of a period of time. The test program should ask the user the annual interest rate, the starting balance, and the number of months that have passed since the account was established. Then a loop should iterate once for every month, performing the following:

ask the user the amount deposited into the account during that month. Then add the amount to the account balance.

ask the user for the amount withdrawn from the account during the month. The subtract the amount from the balance

calculate the monthly interest

After the last iteration, the program should display the ending balance, the total amount of deposits, the total amount of withdrawals, and the total interest earned.

Similar questions