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
All states that have altered judicial selection techniques in recent years have adopted some form of:
BigorU [14]

Answer:

Merit Selection.

Answer choice D.

4 0
3 years ago
Read 2 more answers
A software development _____________ provides a framework for designing, writing, and testing software.
Ivenika [448]
I think methodology
4 0
3 years ago
Having a legitimate reason for approaching someone to ask for sensitive information is called what?
PIT_PIT [208]
It’s called Impersonation
5 0
3 years ago
At least 20 characters
coldgirl [10]

Answer:

eh?

Explanation:

eh?

6 0
3 years ago
Design a 3-bit counter that follows the sequence: 1, 4, 6, 3, 7, 1, 4, 6, 3.... Unused states (0, 2, 5) must go to a used state.
Ann [662]

Answer:

This question is incomplete, here's the complete question:

Design a 3-bit counter that follows the sequence: 1, 4, 6, 3, 7, 1, 4, 6, 3.... Unused states (0, 2, 5) must go to a used state. Use the binary value of the count for each state assignment. So the sequence in binary will be 001, 100, 110, 011, 111, 001, 100, 110, 011.... Use D flip-flops. Repeat using X flip-flops. Note: There is no output to this state machine. The count (state) itself is what is desired.

Explanation:

kindly check the attached images below to see the step by step solution to the question above

3 0
4 years ago
Other questions:
  • HELP PLEASE!!!!!!!!
    10·1 answer
  • ________ is a type of attack in which the attacker takes control of a session between two machines and masquerades as one of the
    5·1 answer
  • How are appointments scheduled in medisoft
    12·1 answer
  • What is one expectation of open-source software?
    15·1 answer
  • Which Windows 7 feature allows a user to open multiple programs at the same time?
    7·1 answer
  • The following are part of characteristics of a software requirement specification.
    6·1 answer
  • What is the purpose of this parallelogram shape in a flowchart?
    15·1 answer
  • In this era of technology, everyone uses emails for mail and messages. Assume you have also used the
    6·1 answer
  • State the domain and range for the following relation. Then determine whether the relation represents a function. A box labeled
    6·1 answer
  • Who is the traitor of UA?<br><br>1 Karishma<br><br>2 Yuga Aoyama<br><br>3 Denki <br><br>4 Mineta
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!