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
____ involves taking data from your database and putting it into an electronic file in a format that another external applicatio
steposvetlana [31]

Answer:

The answer is "Option c".

Explanation:

In the database dumping a folder for configuration, which information in the file is called a document spill.  In Plesk, exporting a database dump is a file that can be used for storage or delivery, and then preserves a source database is known as Exporting, and other choices are not correct, that are described as follows:

  • Importing, It is a dump in a database, that includes retrieving data from the data in a database location, that's why it's wrong.
  • Enhancing, It automatically improves data, that's why it's wrong.
  • Extracting, It is used in data analyzing and trapped to obtain necessary data from sources, that's why it is wrong.
3 0
3 years ago
Part B How could installing new technology, such as scrubber machines, affect the factories required to install them? Name a pos
Verdich [7]

Answer:It will decrease harmful emissions, so the factories will no longer need to install them.

Explanation:

This helps improve the safety of the surrounding community and workers. But this technology is expensive and required time and effort to install.

5 0
2 years ago
World Book is a/an A. Social media platform. B. Textbook. C. Almanac. D. Encyclopedia.
Nadusha1986 [10]
D. Encyclopedia
Not a b or c
8 0
3 years ago
Read 2 more answers
Arpenet was the computer created by the military true or false
Sphinxa [80]

True. It was a project that the pentagon was working on in the 60's

3 0
3 years ago
How's your day :D I hope its goin well you amazing person :D
Rainbow [258]

Answer:

You are an awesome and amazing person!!

Explanation:

7 0
3 years ago
Read 2 more answers
Other questions:
  • What view is In a presentation program displays your slides in full screen mode
    6·1 answer
  • What is the post condition of an expression or variable
    11·1 answer
  • Does any one play sniper clash 3d ??? ​
    9·2 answers
  • Define an I/O port. Which functions are performed by it?
    10·1 answer
  • What field in a TCP segment is used to determine if an arriving data unit exactly matches the data unit sent by the source?
    11·1 answer
  • i need to also do a algorithm where if the total is a even number 10 points are added to the score and if the total is odd then
    11·1 answer
  • Which of these are examples of a bug?
    6·1 answer
  • Cuántos tipos de grua existen en el mundo​
    7·1 answer
  • When creating a study schedule, why is it important to be realistic about how much time everything requires?
    8·2 answers
  • Computer simulations were first developed during __________<br> as a part of the _____________
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!