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
Define a function calc_pyramid_volume with parameters base_length, base_width, and pyramid_height, that returns the volume of a
Sever21 [200]

The missing segment of the code illustrates the use of functions.

Functions are also referred to as <em>procedures or methods</em>; they are set of instructions that act as one.

The code segment that complete the code in the question is as follows:

<em>def calc_pyramid_volume(length, width, height): </em>

<em>    baseArea = length * width </em>

<em>    Volume = baseArea * height * 1/3 </em>

<em>    return Volume</em>

<em />

<em />

The first line of the code segment declares the function itself

<em>def calc_pyramid_volume(length, width, height):</em>

Then, the base area of the pyramid is calculated

<em>    baseArea = length * width</em>

Then, the volume of the pyramid is calculated

<em>    Volume = baseArea * height * 1/3</em>

Lastly, the volume is returned to the main method

<em>    return Volume</em>

So, the complete code (without comments) is:

<em>def calc_pyramid_volume(length, width, height): </em>

<em>    baseArea = length * width </em>

<em>    Volume = baseArea * height * 1/3 </em>

<em>    return Volume </em>

<em>     </em>

<em>length = float(input()) </em>

<em>width = float(input()) </em>

<em>height = float(input()) </em>

<em>print('Volume for', length, width, height, "is:", calc_pyramid_volume(length, width, height))</em>

<em />

See attachment for the sample run

Read more about functions at:

brainly.com/question/17225124

8 0
2 years ago
HELP 99PTS If Answered
Alborosie

You will have to do this as we are not you and we do not know local business/websites. Sorry we could not help.

3 0
3 years ago
Read 2 more answers
The user cannot use a computer system without.................... software<br><br>​
zheka24 [161]

Answer:

the user cannot use a computer system without hardware and software

4 0
3 years ago
Read 2 more answers
Assignment 1: silly sentences edhesive
Genrish500 [490]

Answer:

print("Let's play Silly Sentences!")

print(" ")

name=input("Enter a name: ")

adj1=input("Enter an adjective: ")

adj2=input("Enter an adjective: ")

adv=input("Enter an adverb: ")

fd1=input("Enter a food: ")

fd2=input("Enter another food: ")

noun=input("Enter a noun: ")

place=input("Enter a place: ")

verb=input("Enter a verb: ")

print(" ")

print(name + " was planning a dream vacation to " + place + ".")

print(name + " was especially looking forward to trying the local \ncuisine, including " + adj1 + " " + fd1 + " and " + fd2 + ".")

print(" ")

print(name + " will have to practice the language " + adv + " to \nmake it easier to " + verb + " with people.")

print(" ")

print(name + " has a long list of sights to see, including the\n" + noun + " museum and the " + adj2 + " park.")

Explanation:

Got it right. Might be a longer version, but it worked for me.

6 0
2 years ago
A contiguous subsequence of a list S is a subsequence made up of consecutive elements of S. For example, if S is 5,15,-30,10,-5,
Sindrei [870]

Answer:

We made use of the dynamic programming method to solve a linear-time algorithm which is given below in the explanation section.

Explanation:

Solution

(1) By making use of the  dynamic programming, we can solve the problem in linear time.

Now,

We consider a linear number of sub-problems, each of which can be solved using previously solved sub-problems in constant time, this giving a running time of O(n)

Let G[t] represent the sum of a maximum sum contiguous sub-sequence ending exactly at index t

Thus, given that:

G[t+1] = max{G[t] + A[t+1] ,A[t+1] } (for all   1<=t<= n-1)

Then,

G[0] = A[0].

Using the above recurrence relation, we can compute the sum of the optimal sub sequence for array A, which would just be the maximum over G[i] for 0 <= i<= n-1.

However, we are required to output the starting and ending indices of an optimal sub-sequence, we would use another array V where V[i] would store the starting index for a maximum sum contiguous sub sequence ending at index i.

Now the algorithm would be:

Create arrays G and V each of size n.

G[0] = A[0];

V[0] = 0;

max = G[0];

max_start = 0, max_end = 0;

For i going from 1 to n-1:

// We know that G[i] = max { G[i-1] + A[i], A[i] .

If ( G[i-1] > 0)

G[i] = G[i-1] + A[i];

V[i] = V[i-1];

Else

G[i] = A[i];

V[i] = i;

If ( G[i] > max)

max_start = V[i];

max_end = i;

max = G[i];

EndFor.

Output max_start and max_end.

The above algorithm takes O(n) time .

4 0
2 years ago
Other questions:
  • A software program that allows a programmer to type in code. modern versions usually make it easy to format the code on the scre
    13·1 answer
  • Dell Computer purchases parts and resources for its computers from multiple suppliers that are spread across the world. This pra
    8·1 answer
  • What device brocasts all data packets to other nodes on a network?
    5·1 answer
  • ​PeroxyChem's IT staff was able to free its IT staff to spend less time on routine maintenance and more time on strategic tasks
    11·1 answer
  • Which of the following statements about take home pay is TRUE?
    10·1 answer
  • Radar devices are used by law enforcement to be sure that individuals are driving safely. They tell the officer how fast the veh
    12·1 answer
  • What option do you use to view your presentation?
    15·1 answer
  • WILL MARK BRAINLIEST FOR ANYONES ANSWER!
    12·1 answer
  • The tag that describes the content of the web page is ________________
    5·1 answer
  • Is each of the following method identifiers (a) legal and conventional, (b) legal but unconventional, or (C) illegal?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!