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
liubo4ka [24]
3 years ago
10

Create a SavingsAccount class. Use a static data member annualInterestRate to store the annual interest rate for each of the sav

ers. Each member of the class contains a private data member savingsBalance indicating the amount the saver currently has on deposit. Provide member function calculateMonthlyInterest that calculates the monthly interest by multiplying the savingsBalance by annualInterestRate divided by 12; this interest should be added to savingsBalance. Provide a static member function modifyInterestRate that sets the static annualInterestRate to a new value. Write a main program to test your class. Your program should prompt the user to enter the savingsBalance for two different accounts. It should ask for the annualInterestRate.
Computers and Technology
1 answer:
andrew-mc [135]3 years ago
4 0

Answer:

see explaination

Explanation:

SavingsAccount.h

#pragma once

#ifndef SAVINGS_H

#define SAVINGS_H

//SavingsAccount class declaration

class SavingsAccount

{

//declare data members

private:

//set annualInterestRate to 0.0 default value

static double annualInterestRate;

double savingsBalance;

public:

//set the balance

void setBalance(double);

//modify interest rates

static void modifyInterestRate(double);

//retruns total balance with interest

double calculateMonthInt();

};

#endif

SavingsAccount.cpp

//include required header files

#include<iostream>

#include"SavingsAccount.h"

using namespace std;

//set the annualInterestRate to 0

double SavingsAccount::annualInterestRate = 0;

//static funtion modify interest rate

void SavingsAccount::modifyInterestRate(double iRate)

{

annualInterestRate = iRate;

}

//set the balance

void SavingsAccount::setBalance(double bal)

{

savingsBalance = bal;

}

//calculating savings balance with monthly interest

double SavingsAccount::calculateMonthInt()

{

double monthInt = 0;

monthInt += savingsBalance*annualInterestRate / 12;

return savingsBalance += monthInt;

}

DriverProgram.cpp

//include required header files

#include<iostream>

#include "SavingsAccount.h"

using namespace std;

//main methods

int main()

{

//delcare class objects

SavingsAccount saver1, saver2;

//setter functions of balance

saver1.setBalance(2000.00);

saver2.setBalance(3000.00);

//Setting annual interset 0.03 to static variable

saver1.modifyInterestRate(0.03);

//finding the balance in saver1 and saver2 account

cout << "Balance of saver1 and saver2 on 3% interest Rate\n";

cout << "--------------------------------------------------\n";

cout << "Balance of saver1 = " << saver1.calculateMonthInt()

<< endl;

cout << "Balance of saver2 = " << saver2.calculateMonthInt()

<< endl << endl;

//Setting annual interset 0.04 to static variable

saver1.modifyInterestRate(0.04);

cout << "Balance of saver1 and saver2 on 4% interest Rate\n";

cout << "---------------------------------------------------\n";

cout << "New Balance of saver1 = " << saver1.calculateMonthInt() << endl;

cout << "New Balance of saver2 = " << saver2.calculateMonthInt() << endl<<endl;

return 0;

}

You might be interested in
Create a script to input 2 numbers from the user. The script will then ask the user to perform a numerical calculation of additi
ohaa [14]

Answer:

The code given is written in C++

First we declare the variables to be used during the execution. The names given are self-explanatory.

Then the program outputs a request on the screen and waits for user input, for both numbers and one more time for the math operation wanted, selected with numbers 1 to 4.

Finally, the program executes the operation selected and outputs the result on screen.  

Code:

<em>#include <iostream> </em>

<em> int main() </em>

<em>{ </em>

<em> // variable declaration </em>

<em> float numberA; </em>

<em> float numberB; </em>

<em> int operation; </em>

<em> float result=0; </em>

<em> </em>

<em> //number request </em>

<em> std::cout<<"Type first number:\n"; std::cin>>numberA; </em>

<em> std::cout<<"Type second number:\n"; std::cin>>numberB; </em>

<em>  </em>

<em> //Operation selection </em>

<em> cout << "Select an operation\n"; </em>

<em> cout << "(1) Addition\n"; </em>

<em> cout << "(2) Subtraction\n"; </em>

<em> cout << "(3) Multiplication\n"; </em>

<em> cout << "(4) Division\n"; </em>

<em> std::cout<<"Operation:\n"; std::cin>>operation; </em>

<em> </em>

<em> switch(operation){ </em>

<em>  case 1: </em>

<em>   result = numberA+numberB; </em>

<em>   break; </em>

<em>  case 2: </em>

<em>   result = numberA-numberB; </em>

<em>   break; </em>

<em>  case 3: </em>

<em>   result = numberA*numberB; </em>

<em>   break; </em>

<em>  case 4: </em>

<em>   result = numberA/numberB; </em>

<em>   break;    </em>

<em>  default: </em>

<em>   std::cout<<"Incorrect option\n"; </em>

<em>  }</em>

<em> //Show result </em>

<em> std::cout<<"Result is:"<<result<<::std::endl; </em>

<em> return 0; </em>

<em>}</em>

5 0
3 years ago
write ms-dos command to list all the files and folders of EIGHT sub directory of C: drive in ascending order according to file n
Anna007 [38]

The dir command displays information about files and directories, and how much disk space is available. By default, it displays the name, size, and last modification time of every file in the current directory.

7 0
3 years ago
Which component of a computing device drains the battery the fastest?(1 point)
Lostsunrise [7]
The display screen since it’s always bright
8 0
3 years ago
Read 2 more answers
In a circular linked list the last node points to the____ node.
horsena [70]

Answer: option A) First

In a circular linked list the last node points to the first node.

Explanation: As in a circular linked list, the node will point to its next node. Since the node next to last node is the first node hence last node will point to first node in a circular way. The elements points to each other in a circular path which forms a circular chain.

4 0
4 years ago
The term composite would be used to describe an image that was altered by the Crop tool.
patriot [66]

Answer:

Would it be false?

5 0
3 years ago
Other questions:
  • After modifying the /etc/default/grub file, what command should be run to rebuild the grub config files?​
    6·1 answer
  • Which app is used to synchronize data among iOS devices and Windows desktops?
    7·2 answers
  • PLEASE DON'T DELETE THIS QUESTION!!!!
    15·2 answers
  • Research information technology affects on job market, career pathways, occupational outlooks in business and finance and synthe
    7·1 answer
  • What do reservations do?
    15·1 answer
  • What does prioritization help you to do?
    12·2 answers
  • Pls help with this (20 points again)
    8·1 answer
  • Device driver issues can come up if you . If this happens, .
    11·1 answer
  • Write a function isCString which accepts as arguments a const pointer to a char array and an integer for the size of the array
    12·1 answer
  • Which cpu type would most likely be found in a smartphone?.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!