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
Consider this binary search tree:______.
Nitella [24]

Answer:

The new root will be 2.

<em></em>

Explanation:

The binary tree is not properly presented (See attachment)

To answer this; first, we need to order the nodes of the tree in a pre-order traversal.

We use pre-order because the question says if something is removed from the left child.

So, the nodes in pre-order form is: 14, 2, 1, 5, 4, 16.

The root of the binary tree is 14 and if 14 is removed, the next is 2.

<em>Hence, the new root will be 2.</em>

7 0
2 years ago
Do the police check your mobile device during police checks?
Marat540 [252]
it depends............

4 0
2 years ago
Read 2 more answers
What some one ask me if i am more of hardware or software person, what is that mean?
balu736 [363]

Answer: Any person or people asking about someone being a hardware or software person displays that they are questioning about the computer knowledge of the person and his/her interest.

The interest can be regarding software tools for programming, designing ,  etc or hardware device like troubleshooting, assembling the computer parts ,etc.

The person persisting good knowledge about software programming language and software is diverted towards software side .The person who likes to deal with hardware parts of the computer system is hardware-oriented person.

7 0
3 years ago
A proactive computer professional will _____. have a neutral outlook toward technology underestimate the impact of technology an
Elodia [21]

Answer:

A proactive computer professional will anticipate future problems and need

Explanation:

This statement is not only true for technology but for any field. Anybody who is proactive will always look for future, will foresee future problems and challenges and get ready to face those. He will simultaneously analyze the present interest and problems and connect the future and prepare himself well to be successful in the future.

For pro-active person’s success is not an end, even after getting succeeded he must work for tomorrow. So thus, the choice is justified with various analytical statement.

4 0
3 years ago
Read 2 more answers
_____ relies on lies and misrepresentation to trick an authorized user into providing information or access to an attacker.
kap26 [50]

Answer:

"Social engineering" is the correct answer for the above question.

Explanation:

  • Social engineering is a process, which gives the idea for the hacker or unauthorized user to get inside the system or hack the system.
  • It is used to read the humans data or psychologically hack human data.
  • It teaches the processor by an attacker to be the master of the authorized user. By this, an attacker can able to know the authorized term with the help of an authorized person.
  • The above question asks about the term, which is used to help the hackers to hack the system. This term is known as Social Engineering.

6 0
3 years ago
Other questions:
  • _____ is two or more connected computers.
    8·1 answer
  • When creating an input control (for example, a button) on a form the _____________ indicates the data that is contained in the n
    13·1 answer
  • Software obtained illegally is called open-source software. true / false
    15·1 answer
  • ​Which SQL keyword is used to search for records?
    8·1 answer
  • Customers access the internet through what usually for a monthly fee
    14·1 answer
  • According to Holpp and Kelly's approaches to developing vision, the benchmarking approach is more internally focused, whereas th
    6·1 answer
  • What is a symptom of a failing power supply? The display has only a blinking cursor. The computer displays a POST error code. Th
    12·1 answer
  • A chef writing up her famed recipe for beef stew realizes she has switched parsley and oregano everywhere in the recipe. The che
    13·1 answer
  • 11.
    9·2 answers
  • Primary functions of lighting are sufficient light to...
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!