# C++ coding assignment | Computer Science homework help

Assg 02: Classes

COSC 2336 Facts Structures

Objectives • Imagine a uncompounded arrange • Practice using <cmath> math characters • Practice after a while C++ string images and I/O exits • Use a arrange doer • Pattern of cupel driven crop

Description Typically, most wholeone economizes capital dateically for privacy. In this employment, for frankness, we postulate that the capital is put into an completionity that pays a ﬁxed concern trounce, and capital is defenceed into the completionity at the end of the speciﬁed date. Divine the individual cautions for privacy defencesD dollarsmtimesperyear. Theaccountpaysr%compoundconcern trounce. And the individual succeed be cautions for a date of t interval absorbed in years. For pattern, the individual command economize D = \$500 whole m = 12 months. The privacy completionity pays 4.8% junction concern per year. And the individual as t = 25 years to economize for privacy. The completion completion of cautionss S assembled at the end of this interval is absorbed by the formula S = Dh(1 + r/m)mt −1 r/m i For pattern, divine that you defence \$500 at the end of each month (m = 12). The completionity pays 4.8% concern per year junctioned monthly for t = 25 years. Then the completion capital assembled into this completionity is

1

500[(1 + 0.048/12)300 −1]/(0.048/12) = 289,022.42

.

On the other operative, divine that you neglect to assemble S dollars in cautionss, and would relish to understand how greatly capital you should defence D each defence date. The dateic reimbursement you deficiency to aim this aim S is absorbed by the formula

D =

S(r/m) (1 + r/m)mt −1 Design a arrange that uses the aloft formulas to apportion privacy cautionss and to aid intent privacy aims. Your arrange should enjoy privy solicitation shiftings (all of image envelop) to wait D the defence completion, m the reckon of defence dates per year, r the concern trounce and t the interval in years the intent succeed economize for privacy. In the arrange name guidelines, I intimidate using sole communication shifting names usually when adaptation legislation. However when we are quickly utensiling a formula in an engineering or scientiﬁc reckoning, it is frequently clearer to use the shifting names quickly as absorbed in the formula. For this provision you deficiency to total the forthcoming tasks. 1. Imagine a arrange denominated RetirementAccount. The arrange should enjoy a arrange doer that charms the 4 shiftings, D, m, r, t as parameters. 2. Imagine a forfeit arrange doer as polite-behaved. This doer can set all of the privy limb shifting prizes to 1.0. 3. You must enjoy getter and setter courses for all 4 of the limb shiftings of the arrange. The courses succeed be denominated set_D(), set_m(), set_r(), set_t() and get_D(), get_m(), get_r(), get_t(), respectively. 4. Imagine a limb character denominated tostring(). This character succeed not charm any parameters as input. It avail a string that represents the prizes/settings of the RetirementAccount arrange. See the pattern output under for the format of the string to be come-backed. 5. Imagine a limb character denominated apportionRetirementSavings(). This character should utensil the ﬁrst formula to apportion the completion completion of cautionss S the completionity succeed engender. This character has no parameters as inputs, and it avail a envelop completion (the completion of cautionss) as its upshot.

2

6. Imagine a limb character denominated intentRetirementDeposits(). This character charms a envelop parameters S as input, which is the cautionss aim you appetition to end. This character should utensil the prevent equation absorbed aloft. The character avail a envelop upshot, D which is the completion of capital that should be defenceed each date to coalesce the cautionss aim S.

As antecedently you succeed be absorbed a set-on-footing template for this provision. The template contains all of the cupels your arrange and limb characters should by for this provision. You should transcribe your program by uncommenting the cupels/legislation in ocean 1 at a interval, and adaptation your arrange incrementally to fruit after a while the cupel. If you total all of the aloft tasks truly, the cupels absorbed to you in the set-on-footing template succeed profit the forthcoming punish output:

=== Testing arrange figment using doer...................

=== Testing getter courses................... Account: D (defence completion) = \$100.00 m (periods per year) = 10.00 r (concern trounce) = 0.0350 t (interval in years) = 22.00

=== Testing tostring() course................... Account: D (defence completion) = \$100.00 m (periods per year) = 10.00 r (concern trounce) = 0.0350 t (interval in years) = 22.00

=== Testing setter courses................... Account: D (defence completion) = \$500.00 m (periods per year) = 12.00 r (concern trounce) = 0.0480 t (interval in years) = 25.00

=== Testing privacy cautionss reckonings...................

3

My privacy cautionss: \$289022.42

=== Testing privacy intentning reckonings................... In ordain to economize 1 darling dollars, we deficiency to find monthly defences of \$1729.97 If we set our defence to this new completion... Account: D (defence completion) = \$1729.97 m (periods per year) = 12.00 r (concern trounce) = 0.0480 t (interval in years) = 25.00

My privacy cautionss: \$1000000.00

=== Prevent cupel on completionity2 of cautionss and intentning................... Totality 2: D (defence completion) = \$650.00 m (periods per year) = 9.00 r (concern trounce) = 0.0350 t (interval in years) = 30.00

My privacy cautionss: \$309521.45

In ordain to economize 2 darling dollars, we deficiency to find defences of \$4200.03 If we set our defence to this new completion... Account: D (defence completion) = \$4200.03 m (periods per year) = 9.00 r (concern trounce) = 0.0350 t (interval in years) = 30.00

My privacy cautionss: \$2000000.00

=== Larger reckon of cupels, assimilate pi of increasing monthly defence completion................... Intent 0: D (defence completion) = \$500.00 m (periods per year) = 12.00 r (concern trounce) = 0.0400 t (interval in years) = 30.00 Completion Savings: 347024.70 Intent 1:

4

D (defence completion) = \$600.00 m (periods per year) = 12.00 r (concern trounce) = 0.0400 t (interval in years) = 30.00 Completion Savings: 416429.64 Intent 2: D (defence completion) = \$700.00 m (periods per year) = 12.00 r (concern trounce) = 0.0400 t (interval in years) = 30.00 Completion Savings: 485834.58 Intent 3: D (defence completion) = \$800.00 m (periods per year) = 12.00 r (concern trounce) = 0.0400 t (interval in years) = 30.00 Completion Savings: 555239.52 Intent 4: D (defence completion) = \$900.00 m (periods per year) = 12.00 r (concern trounce) = 0.0400 t (interval in years) = 30.00 Completion Savings: 624644.46 Intent 5: D (defence completion) = \$1000.00 m (periods per year) = 12.00 r (concern trounce) = 0.0400 t (interval in years) = 30.00 Completion Savings: 694049.40 Intent 6: D (defence completion) = \$1100.00 m (periods per year) = 12.00 r (concern trounce) = 0.0400 t (interval in years) = 30.00 Completion Savings: 763454.34 Intent 7: D (defence completion) = \$1200.00 m (periods per year) = 12.00 r (concern trounce) = 0.0400 t (interval in years) = 30.00

5

Total Savings: 832859.29 Intent 8: D (defence completion) = \$1300.00 m (periods per year) = 12.00 r (concern trounce) = 0.0400 t (interval in years) = 30.00 Completion Savings: 902264.23 Intent 9: D (defence completion) = \$1400.00 m (periods per year) = 12.00 r (concern trounce) = 0.0400 t (interval in years) = 30.00 Completion Savings: 971669.17

Hints • You can use the string image and string continuity to transcribe the claimd tostring() limb character. For pattern, if I had shiftings x and y of image int and envelop, and I neglected to imagine a string from them to come-back, I could do bigwig relish

#embody <string> using namespace std;

int x = 5; envelop y = 0.035 string s = "x (pattern int) = " + to_string(x) + 'n' + "y (pattern envelop) = " + to_string(y) + 'n'; However, you cannot guide the preciseness (reckon of decimal places shown)oftheoutputusingtheto_string()method. Iwillacceptthis, but if you neglect to get precisely the similar output I showed in the punish output, you succeed deficiency to use the string exit library <sstream>. This library allows you to imagine a exit, relish the cout exit, but exit into a string. Thus you can use the io manipulator characters relish setprecision() and unroving to format the decimal reckons. You can contemplate at the set-on-footing template for divers patterns of using these I/O manipulators to format the output. • You should use the pow() character from <cmath> for careful the

6

savings and intentning the aim defences characters. It command find it easier on you, and be past readable, to deﬁne bigwig relish:

// r is every-year trounce, so completion if concern each date is // absorbed by r/m envelop trouncePerDeposit = r / m; // completion reckon of defences envelop reckonOfDeposits = m * t; • Almost all of the legislation absorbed in the template is commented out. You should set-on-foot by barely uncommenting the ﬁrst thread that imagines an aim using your doer, this one:

// RetirementAccount completionity(100.00, 10.0, 0.035, 22.0); Get your doer fruiting ﬁrst for your arrange. Then you should uncomment out the ﬁrst thread cupeling the get_D() getter course, etc. E.g. if you are not used to coding incrementally, try it out. Legislation barely a sole character and get it fruiting antecedently doing the proximate one. This is a image of cupel driven crop.

Assignment Dependence A MyLeoOnthread dependence folder has been imagined for this provision. You should attract and upload your totald .cpp beginning ﬁle to the dependence folder to total this provision.

Requirements and Grading Rubrics Program Execution, Output and Functional Requirements 1. Your program must calm, run and profit some kind of output to be graded. 0 if not satisﬁed. 2. 25 pts. The arrange must enjoy the requested limb shiftings. These limb shiftings must be privy. 3. 25 pts. The doer is imagined and fruiting truly. 4. 10 pts. All setter and getter courses for the 4 limb shiftings are utensiled and fruit as asked for.

7

5. 10pts. YouhavecorrectlyimplementedthecalculateRetirementSavings() character, and it is careful cautionss truly. 6. 10pts. YouhavecorrectlyimplementedtheplanRetirementDeposits() character, and it it careful aim defences truly. 7. 10 pts. You enjoy truly utensiled the tostring() course. The course is come-backing a string (not sending quickly to cout). 8. 2 pts. (bonus) You used <sstream> string exits, and enjoy truly formatted the string to enjoy 2 or 4 decimal places as shown in punish output. 9. 5 pts. All output is punish and matches the punish pattern output. 10. 5pts. Followedclassstyleguidelines, especiallythosementionedbelow.

Program Name Your programs must adapt to the name and formatting guidelines absorbed for this arrange. The forthcoming is a schedule of the guidelines that are claimd for the provision to be submitted this week.

1. Mostimportantly, findsureyouﬁgureouthowtosetyoursolution settings truly. All programs must use 2 spaces for all solution levels, and all solution levels must be truly indented. Also all tabsmustberemovedfromﬁles,andonly2spacesusedforindentation. 2. A character header must be introduce for limb characters you deﬁne. You must impart a brief term of the character, and muniment all of the input parameters to the character, as polite-behaved-behaved as the come-back prize and facts image of the character if it avail a prize for the limb characters, symmetrical relish for symmetrical characters. However, setter and getter courses do not claim character headers. 3. You should enjoy a muniment header for your arrange. The arrange header muniment should impart a term of the arrange. Also you should muniment all privy limb shiftings that the arrange manages in the arrange muniment header. 4. Do not embody any statements (such as scheme("pause") or inputting a key from the user to endure) that are meant to haunt the ultimate from going abroad. Do not embody any legislation that is speciﬁc to a sole

8

operating scheme, such as the scheme("pause") which is Microsoft Windows speciﬁc.

(File deficiency to be in '.cpp'. Use any C++ calmrs but the legislation must be fruiting.

Basic features
• Free title page and bibliography
• Unlimited revisions
• Plagiarism-free guarantee
• Money-back guarantee
On-demand options
• Writer’s samples
• Part-by-part delivery
• Overnight delivery
• Copies of used sources
Paper format
• 275 words per page
• 12 pt Arial/Times New Roman
• Double line spacing
• Any citation style (APA, MLA, Chicago/Turabian, Harvard)

# Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

### Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

### Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

### Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

### Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

## Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
\$26
The price is based on these factors: