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
What material replaced stone as the primary materials used to make tools and machines by humans
swat32

steel is pretty common, if not metal

4 0
4 years ago
Consider the language S*, where S = {a ab ba}.
Nezavi [6.7K]

Answer:

Check Explanation

Explanation:

A) the string (abbba) is not a word in this language because in this language, each b must preceded or followed by an a. Three consecutive b's are just not possible.

B) All the words with 3 letters in this language

aaa

aab

aba

baa

C) 5 words with four letters from this language. I'll write as many as possible to make things as easy as possible.

aaaa

aaab

aaba

baab

baba

baaa

abaa

abab

abba

D) This is the language of words without bbb, with every bb preceded and followed by an a (that is, no word can start or end wilth bb). All non-empty strings contain at least one a (so b and bb together are not allowed!).

Hope this Helps!!!

6 0
3 years ago
What does this comparison block indicate?
natima [27]

Answer:

This comparison block indicates that the comparison is true if the left side is equal to the right side.

Explanation:

The comparison uses the = operator, which is the assignment operator in most programming languages. This operator is used to assign a value to a variable. In this case, the comparison is checking whether the value of the getItem variable is equal to 5. If the value of getItem is equal to 5, then the comparison will evaluate to true. If the value of getItem is not equal to 5, then the comparison will evaluate to false.

5 0
1 year ago
A lead views a specific page on your website, say, your case study page. You then send targeted follow-up content like one of yo
IRINA_888 [86]

Answer:

Behavioral Email                                

Explanation:

A behavioral email is an automated email which is sent to recipients on the basis of their behavior. These emails are sent after a user communicates with a business on social media, the company’s website, email, and other communication medium. Behavioral emails help to grow customer involvement and sales. Behavioral email can also be used as a marketing strategy, used by marketers to gather data about an email subscriber in order to send targeted content to that subscriber on the basis of his behavior or actions. When the marketer sends an email to the customer, it is appropriate for that customer, based on the data gathered and their current monitored behavior. Behavioral email helps to understand costumer needs. It helps to get an idea of a customers preferences by inspecting his behavior.

5 0
3 years ago
Define what is meant by an entity in a data model. How should an entity be named? What information about an entity should be sto
AURORKA [14]

Answer:

Check the explanation

Explanation:

An entity can be a person, place, thing, or even an event about which data is collated and stored. Entities names usually are nouns.

The Entity Data Model (EDM) is an extensive model of the Entity-Relationship model which identifies the conceptual model of the data using a variety of modeling technique. It acan also be termed as a set of concepts that illustrates data structure, regardless of its stored form.

The Information stored or can be stored in a CASE repository regarding an entity includes:

Name

Definition

Special Notes

7 0
3 years ago
Other questions:
  • Race conditions are possible in many computer systems. Consider a banking system with two methods: deposit(amount) and withdraw(
    14·1 answer
  • Please help!
    10·1 answer
  • All of the following are good reasons to attend a cummunity college except
    10·2 answers
  • What is the area of a triangle whose base is 14 m and whose height is 22 m?
    7·1 answer
  • ____ is (are) the abuse of e-mail systems to send unsolicited e-mail to large numbers of people.
    14·1 answer
  • A virus that is embedded in the automatically executing scipts commonly found in word processors, spreadsheets, and database app
    13·2 answers
  • Assume the existence of a BankAccount class with a constructor that accepts two parameters: a string for the account holder's na
    14·1 answer
  • Your one output statement should occupy two lines in your program
    13·1 answer
  • Consumers who wish to make a purchase from other consumer on ebay need tl
    10·1 answer
  • It is a type of web page that allows you to share your ideas experiences and beliefs
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!