Write a modular program that calculates the total amount of

Write a modular program that calculates the total amount of interest earned for a group of bank accounts. The user should be allowed to specify the number of bank accounts. The amount of interest earned on a single account can be calculated by multiplying the account balance by the percent interest. Use the information in the table below to calculate the interest on an account.

Type of Account

Account Balance

Percent Interest

Checking

< $100

0

Checking

$100 - $1,000

.001

Checking

> $1,000

.002

Savings

<= $100

0

Savings

> $100

.015

Your program must use parallel arrays to store the information about the bank accounts – type of account (string) and balance (floating point). These arrays must NOT be declared globally.

Prompt the user for the type of account and the account balance. Use a menu to prompt the user for the type of account rather than letting them type in checking or savings.

Validate the user\'s input for account balance so that values less than 0 are not accepted.

Once the required information for all the bank accounts has been entered into arrays, then calculate the interest earned for each bank account storing the results in another parallel array – interest (floating point).

Use global constants for the percent interest.

Once the interest earned on each of the accounts has been calculated and stored in an array, then calculate and display the total amount of interest earned on all the accounts.

Dollar amounts should be properly formatted.

NOTE: Make sure your modular program includes some functions that accept input and return values.

Type of Account

Account Balance

Percent Interest

Checking

< $100

0

Checking

$100 - $1,000

.001

Checking

> $1,000

.002

Savings

<= $100

0

Savings

> $100

.015

Solution

#include<iostream>
#include<string>
#include <iomanip> // std::setw
//define MAX size array can hold
#define MAX 100
using namespace std;
const float percent_interset[] = { 0,0.001,0.002,0,0.015};
//function declarations
int menu();
//function to calculate interest for all account and store in array interest
void calculate_interest(string account_type[],float balance[] ,int size,float interest[]) ;
//function to display the total amount of interest earned on all the accounts
void display(string account_type[],float balance[] ,int size,float interest[]) ;
int main()
{
   //declare local variables to store type of account and balance
   string account_type[MAX];
   float balance[MAX];
   float interest[MAX];
   //int choice for allowing user to enter choice of operation
   int choice;
   //array index for two parallen arrays account_type and balance
   int i = 0,j=0;
   while(1)
   {
       choice = menu();
       switch(choice)
       {
           case 1:
               account_type[i] = \"Checking\";
                   cout<<\"Enter balance amount for Checking account : \";
                   cin>>balance[i];
                   ++i;
                   break;
           case 2:
                   account_type[i] = \"Savings\";
                   cout<<\"Enter balance amount for Svaings account : \";
                   cin>>balance[i];
                   ++i;
                   break;
           case 3:
               calculate_interest(account_type,balance,i,interest);
                   break;
           case 4:
               display(account_type,balance,i,interest);
                   break;
           case 5:
               cout<<\"Quit from Application ..\"<<endl;
                   break;
           default:
               cout<<\"Choose correct choice from menu \"<<endl;
                   break;
       }
       if(choice == 5)
           break;
   }
}

int menu()
{
   int choice;
   cout<<\"#################Menu###################\"<<endl;
  
   cout<<\"Enter Any of the below choice \"<<endl;
   cout<<\"1: Checking\ 2: Savings\ 3: calculate percentage\ 4: Display\ 5: Quit \ \";
   cin>>choice;
   return choice;
}

//function to calculate interest for all account and store in array interest
void calculate_interest(string account_type[],float balance[] ,int size,float interest[])
{
   int i ;
   //calculate interest for all account types
   for( i = 0 ; i < size; i ++)
   {
       if( (account_type[i]==\"Checking\") && balance[i] < 100 )

       {
          
           interest[i] = balance[i] * percent_interset[0];
           balance[i] +=interest[i];
       }
       if((account_type[i]==\"Checking\") && ( balance[i] >= 100 && balance[i] <= 1000))
       {
           interest[i] = balance[i] * percent_interset[1];
           balance[i] +=interest[i];
       }
       if( (account_type[i]==\"Checking\") && balance[i] > 1000 )
       {
           interest[i] = balance[i] * percent_interset[2];
           balance[i] +=interest[i];
       }
       if( ((account_type[i]==\"Savings\") && balance[i] <= 100 ))
       {
           interest[i] = balance[i] * percent_interset[3];
           balance[i] +=interest[i];
       }
       if( (account_type[i]==\"Savings\") && balance[i] > 100 )
       {
           interest[i] = balance[i] * percent_interset[4];
           balance[i] +=interest[i];
       }
   }
}
//function to display the total amount of interest earned on all the accounts
void display(string account_type[],float balance[] ,int size,float interest[])
{
   int i ;
   //display for all account types
   cout<<\"##########################################################################\"<<endl;
   for( i = 0 ; i < size; i ++)
   {
      
       std::cout << std::setw(15);
       cout<<\"Type of Account\\t\\tAccount Balance\\t\\tInterest Earned\"<<endl;
       std::cout << std::setw(15);
       cout<<account_type[i]<<\"\\t\\t\"<<\"$\"<<balance[i]<<\"\\t\\t\\t\"<<setw(15)<<interest[i]<<endl;
      
   }
   cout<<\"##########################################################################\"<<endl;
}

---------------------------------------------------------

output

#################Menu###################
Enter Any of the below choice
1: Checking
2: Savings
3: calculate percentage
4: Display
5: Quit
4
##########################################################################
Type of Account Account Balance Interest Earned
Savings $100 0
Type of Account Account Balance Interest Earned
Checking $1202.4 2.4
Type of Account Account Balance Interest Earned
Savings $1421 21
Type of Account Account Balance Interest Earned
Checking $89 0
Type of Account Account Balance Interest Earned
Checking $550.55 0.55
##########################################################################
#################Menu###################
Enter Any of the below choice
1: Checking
2: Savings
3: calculate percentage
4: Display
5: Quit

Write a modular program that calculates the total amount of interest earned for a group of bank accounts. The user should be allowed to specify the number of ba
Write a modular program that calculates the total amount of interest earned for a group of bank accounts. The user should be allowed to specify the number of ba
Write a modular program that calculates the total amount of interest earned for a group of bank accounts. The user should be allowed to specify the number of ba
Write a modular program that calculates the total amount of interest earned for a group of bank accounts. The user should be allowed to specify the number of ba

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site