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
Given the following declaration, what is the value of b[ 1 ][ 0 ]? int b[ 2 ][ 2 ] = { { 1 }, { 3 , 4 } };
slavikrds [6]

Based on the declaration "int b[ 2 ][ 2 ] = { { 1 }, { 3 , 4 } };" given, the value of b[ 1 ][ 0 ] is equal to 3.

<h3>What is Python?</h3>

Python can be defined as a high-level programming language that is designed and developed to build websites and software applications, especially through the use of dynamic commands (semantics), declarations, functions, and data structures.

<h3>What is an int?</h3>

Int is an abbreviation for an integer and it can be defined as a whole number that may either be positive, negative, or zero.

Based on the declaration "int b[ 2 ][ 2 ] = { { 1 }, { 3 , 4 } };" given, we can infer and logically deduce that the value of b[ 1 ][ 0 ] is equal to 3.

Read more on Python integers here: brainly.com/question/18761825

#SPJ1

8 0
1 year ago
The game often becomes stuck on landscape mode when tilting the device during gameplay, which cuts off some peripheral text. A w
ch4aika [34]

Answer:

The overview of the given situation is described in the explanation segment below.

Explanation:

  • Bug Severity seems to be the extent of influence that somehow a fault will have on the device, while its primary concern is indeed the command of severity that had already affected that same device.
  • You should consider this error as top importance as another framework hangs. I would say you may be lacking the configuration manager settings in your system.

Therefore the above is the right answer.

3 0
2 years ago
3. Coaxial/telephone cable sends<br> during the data transmission<br> signal
Vlad1618 [11]

Answer:

high frequency signal.

3 0
2 years ago
QUESTION: Which is not an example of a video port or cable?
Vikki [24]

Answer:

Radio Corporation of America (RCA)

Explanation:

A corporation is not a video connector.

8 0
3 years ago
Ana is a music lover. She loves to download songs and videos on her computer every time she hears a new song. One day, her compu
o-na [289]

Answer:

Storage outage

As many new songs are released to the Internet every day, Anna might have download thousands of them, which made her computer ran out of storage and RAM(random access memory )

5 0
2 years ago
Other questions:
  • O novo funcionário da equipe de desenvolvimento de sistemas está aprendendo os termos mais utilizados no dia a dia da empresa. A
    7·1 answer
  • Suppose the price of a complement to LCD televisions falls. What effect will this have on the market equilibrium for LCD​ TVs? T
    13·1 answer
  • Which statement best describes the purpose of the Insert Function dialog box?
    13·1 answer
  • The famous study entitled ""Protection Analysis: Final Report"" focused on a project undertaken by ARPA to understand and detect
    14·1 answer
  • Ok.,so i have a sopitify account and by accident i pressed the downlaod on button and it says start you free trial i pressed tha
    11·2 answers
  • PLZ HELP I AM TIMED!!!!
    11·2 answers
  • So im new how exactly does this point system work???​
    6·1 answer
  • Please help!!
    6·1 answer
  • Where else can the computer send the results of processing other than to output​
    13·1 answer
  • Is TCP really more secure than other L4 protocols by default?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!