1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
dedylja [7]
3 years ago
15

"Write a program that calculates the balance of a savings account at the end of a period of time. It should ask the user for the

annual interest rate, the starting balance, and the number of months that have passed since the account was established. A loop should then iterate once for every month, performing the following: Ask the user for the amount deposited into the account during the month. (Do not accept negative numbers.) This amount should be added to the balance. Ask the user for the amount withdrawn from the account during the month. (Do not accept negative numbers.) This amount should be subtracted from the balance. Calculate the monthly interest. The monthly interest rate is the annual interest rate divided by 12. Multiply the monthly interest rate by the balance, and add the result to the balance. 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. The program should write the following data to an .txt file: ending Balance amount of deposits amount of withdrawal and the amount of interest earned Once the file has been written, display to the user that the 'Report written to Report.txt" c++
Computers and Technology
1 answer:
Akimi4 [234]3 years ago
6 0

Answer:

#include <iostream>

#include <fstream>

using namespace std;

int main() {

// Definitions

       double annualInterest;          // The annual interest rate

       double balance;                 // The account balance

       int months;                     // Total number of months

       double totalDeposit  = 0.0;     // Total deposited value

       double totalWithdraw = 0.0;     // Total withdrawn value

       double earnedInterest= 0.0;     // The earned amount

       double deposited;               // Monthly deposited value

       double withdrawn;               // Monthly withdrawn value

// Get the initial required data.

       

       cout<<"Please enter the annual interest rate,\n";

       cout<<"   Interest rate: ";

       cin >>annualInterest;

       cout<<"--------------------------------------------\n";

       cout<<"Please enter the starting balance,\n";

       do{

           cout<<"[the number could not be negative]\n";

           cout<<"Starting Balance: ";

           cin >>balance;

       }while(balance<0);

       cout<<"--------------------------------------------\n";

       cout<<"Please enter the number of months,\n";

       do{

           cout<<"[the number could not be less than 0]\n";

           cout<<"Number of months: ";

           cin >>months;

       }while(months<0);

// Iterated Loop to get all the months data.

       for(int month=1; month <= months; month++){

// Get the deposited value during that month.

           cout<<"Enter the deposited value during month "

               <<month<<",\n";

           do{

               cout<<"[the value could not be less than 0]\n";

               cout<<" Deposited value: ";

               cin >>deposited;

           }while(deposited<0);

           

           totalDeposit += deposited;

           balance += deposited;

// Get the withdrawn value during that month.

           cout<<"Enter the withdrawn value during month "

               <<month<<",\n";

           do{

               cout<<"[the value could not be less than 0]\n";

               cout<<" Withdrawn value: ";

               cin >>withdrawn;

           }while(withdrawn<0);

           

           totalWithdraw += withdrawn;

           balance -= withdrawn;

// Negative balance close the program.

           if(balance < 0){

               cout<<"Sorry, the account has been closed due to\n";

               cout<<"the negative balance.\n";

                 break;

// Calculate value due to the interest rate.

           }

      else {

               earnedInterest += (annualInterest/12) * balance;

               //        monthly interest rate

               balance += (annualInterest/12) * balance;

           }

       }

  // Display the statistics,

      ofstream file;

      file.open ("Report written to Report.txt");

      file << "Report written to Report.txt\n";

       file.close();

       cout<<"The ending balance: "<<balance<<std::endl;

       cout<<"   Total deposited: "<< totalDeposit<<std::endl;

       cout<<" Total withdrawals: "<< totalWithdraw<<std::endl;

       cout<<"   Earned interest: "<< earnedInterest<<std::endl;

       cout<<"============================================\n";

 return 0;

   }

   

You might be interested in
Photographing during the midday can produce which of the following?
deff fn [24]
It can produce harsh shadows
5 0
2 years ago
Read 2 more answers
The default setting for a secondary zone's refresh interval is how many minutes
Vinil7 [7]
The default value at which a refresh interval (an interval a sec. server check for zone updates) is 15 minutes.
If this value is increased, the network traffic is reduced. In the eventuality that the refresh interval expires, the secondary zone will contact the primary zone and request it to initiate the zone transfer.
4 0
3 years ago
Wamna play mm2<br><br><br>imma send u my username​
SashulF [63]

Answer:

sure send it lol but how

6 0
2 years ago
Problem statement: Using loop, write a program that will ask the user to enter a character for left or right. Then, the user wil
zvonat [6]
Define variables
left is l
right is r

Ask input
left or right

Ask input value

Equate l or r to the input value

Show ladder with steps equal to input value and in the side of input variable
7 0
3 years ago
1. How many column can you insert in a MS Word in maximum?
tigry1 [53]

Answer:

63 columns

Explanation:

In Microsoft Word you can insert a table with up to 63 columns, that is the limit to the number of columns allowed in a Word document.

<em>brainliest</em><em>? </em><em>plz! </em>

3 0
3 years ago
Other questions:
  • Write a C program to calculate monthly payment and print a table of payment schedule for a fixed rate loan.
    7·1 answer
  • In the u.s.all financial institutions are required to conduct business at a physical location only
    9·1 answer
  • A(n) ____ tag is used to let the compiler know that your intention is to override a method in a parent class
    10·1 answer
  • Write a shell (text-based) program, called sum_second.py, that opens a text file called stuff.txt with 2 numbers per line separa
    8·1 answer
  • Write a program that produces this output:
    10·1 answer
  • Do you think boot-camp-style treatment centers can help young. People kick smartphones addictions?
    14·2 answers
  • Explain word processing ​
    11·2 answers
  • Write a c program to count the total number of commented characters and words in a c file taking both types of c file comments (
    11·2 answers
  • Choose the best answer from the drop-down menu. A ______ allows multiple connections to a single signal. Without a ______, conne
    7·2 answers
  • At a family reunion, your cousin takes a picture of both of you with her phone, orders a print of it, and mails it to you with a
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!