Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Programming Language Expert

The following formula will compute the Total Amount that will be accumulated for a given Monthly Amount saved:

Notice that his formula also requires that you first calculate a factor and then use it in your formula. The factor formula is:

factor = exp( numberOfMonths * log(1 + monthlyInterestRate))

exp and log are predefined mathematical functions, located in the C++ library.

For hand calculating results to test your program, the equivalent algebraic equation is:

factor = (1 + monthlyInterestRate) numberOfMonths

Write a program to output accumulated values for each month, given a set amount saved each month, until the accumulated amount reaches a set goal amount.

Discussion about comparing floating point values:

Given two floating point values:

num = 9.99999999

num2 = 10.00000000

If both are displayed to two decimal places, you will see:

10.00 and 10.00

However, if you compare the same two values within your code, to see if they are equal, the

comparison test will be false (i.e. they are not equal).

This can cause problems for programs that compare floating point values.

But we can fix this problem by forcing the stored value to be rounded to 2 decimal places (not

just the output value).

The formula:

num = floor((num * 100) + 0.5) / 100.0;

will change the value stored in num to be:

num = 10.00000000

And then if you compare num with num2, they will be found to be equal.

Requirements:

Ensure that you define constants for all fixed values. After defining the constants:

- Use only the constant name in your code (no hardcoded constant values).

- The usage of only constant names includes references in the executable code, the prompts and error messages, and the comments -- no hardcoded values anywhere!

Use the double data type for all floating point values.

The program should:

. Tell the user what the program does before prompting for input.

. Read from the user the amount that will be saved each month.

o The user must enter a value between $5 and $5000 inclusive. If they do not, issue an error message and then re-prompt the user to enter the number again, until a valid value is entered.

. Read from the user the annual interest rate.

o The user must enter a value between 1% and 25% inclusive. If they do not, issue an error message and then re-prompt the user to enter the number again, until a valid value is entered.

o After reading a valid value, the program will need to convert the annual interest rate to a monthly interest rate (divide by 100 to get a fractional interest rate, and then divide that by 12 for monthly interest) before using it in the formulas.

. Read from the user the goal amount they wish to reach.

o The user must enter a positive amount of no more than $ 999,999.99 (i.e. under 1 million). If they do not, issue an error message and then re-prompt the user to enter the number again, until a valid value is entered.

. Determine the factor and the total amount accumulated as calls to two different user-defined functions.

o The first function will return the factor for a specific number of months.

o The second function will return the total amount accumulated for a specific number of months

o Pass any required information, including the number of months to calculate the value for, to the functions as parameters.

. Display the month number and the total amount accumulated, for every month until the goal is reached, formatted as shown in the output example below.

o NOTE: Use the rounding formula provided above to round the value returned from the function and stored in the total amount accumulated variable to 2 decimal places, before comparing it to any other value.

. The program should cease displaying these values as soon as the total amount accumulated is at or above the goal.

. After the goal has been reached, display the annual interest rate, savings per month, total number of months, and final amount accumulated formatted as shown in the output example below.

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M92028980
  • Price:- $40

Priced at Now at $40, Verified Solution

Have any Question?


Related Questions in Programming Language

Question 1 what is a computer program what is structured

Question: 1. What is a Computer program? What is structured programming? 2. What is modular programming? Why we use it? 3. Please evaluate Sin (x) by infinite series. Then write an algorithm to implement it with up to th ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Structs and enumsoverviewin this task you will create a

Structs and Enums Overview In this task you will create a knight database to help Camelot keep track of all of their knights. Instructions Lets get started. 1. What the topic 5 videos, these will guide you through buildi ...

Assignment - haskell program for regular expression

Assignment - Haskell Program for Regular Expression Matching Your assignment is to modify the slowgrep.hs Haskell program presented in class and the online notes, according to the instructions below. You may carry out th ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Overviewthis tasks provides you an opportunity to get

Overview This tasks provides you an opportunity to get feedback on your Learning Summary Report. The Learning Summary Report outlines how the work you have completed demonstrates that you have met all of the unit's learn ...

Task arrays and structsoverviewin this task you will

Task: Arrays and Structs Overview In this task you will continue to work on the knight database to help Camelot keep track of all of their knights. We can now add a kingdom struct to help work with and manage all of the ...

Task - hand execution of arraysoverviewin this task you

Task - Hand Execution of Arrays Overview In this task you will demonstrate how arrays work by hand executing a number of small code snippets. Instructions Watch the Hand Execution with Arrays video, this shows how to ste ...

Question - create a microsoft word macro using vba visual

Question - Create a Microsoft Word macro using VBA (Visual Basic for Applications). Name the macro "highlight." The macro should highlight every third line of text in a document. (Imagine creating highlighting that will ...

Task silly name testeroverviewcontrol flow allows us to

Task: Silly Name Tester Overview Control flow allows us to alter the order in which our programs execute. Building on our knowledge of variables, we can now use control flow to create programs that perform more than just ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As