Write a program to output accumulated values for each month

Assignment Help Programming Languages
Reference no: EM131274258

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.

Reference no: EM131274258

Questions Cloud

Create application that would allow student to enter amount : Create an application that would allow the student to enter the amount of money a customer owes and the amount of money the customer paid.
Student class and a client program : Design, code in Java, test and document (at least) two classes - a Student class and a client program, as follows: Write a Java class called Student which can be used to represent the details of a Student together with some associated operations.
How would his development at midlife differ depending : Describe the physical, social, cognitive, and emotional development of Jeff as he has transitioned from early adulthood into middle adulthood. Predict Jeff's development as he moves through middle adulthood and into late adulthood.
Create a program to keep track of vehicle tire purchases : Create a program to keep track of vehicle tire purchases. The program will store data about the vehicle, the tire manufacturer and size, quantity purchased, the date of sale, and the mileage warranty, etc.
Write a program to output accumulated values for each month : 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.
Impact of motivation on employees performance : Literature review related investigate the impact of motivation on employee's performance
Program should promptthe user to enter the value : Write a program that calculates the average of N integers. The program should promptthe user to enter the value for N and then afterward must enter all N numbers.
What consequences might be expected : Discuss the following case in terms of virtue, non-malfeasance, and honesty. Can you identify examples of each (or their opposites) in the case study as written? Where and by whom? Explain your answers. Please do not get emotionally or personally ..
Perform simulation runs under steady state conditions : 21526 &NM 951 - Marine Engineering Simulation & Modelling - perform simulation runs under steady state conditions for 40%, 50%, 65%, 90% and 100% loads. Compare the main engine operating parameters with the engine manufacturer provided data, which ..

Reviews

Write a Review

Programming Languages Questions & Answers

  Web programming

Work through the project instructions using the provided base files. Please note the detailed grading rubric included in the instruction document

  Design program to accepts account number

Design a program that accepts an account number, the account owner's first and last names, and a balance. Print the projected running total balance for each year for the next 20 years.

  Explain about lexical analyzer

Explain about Lexical Analyzer

  Find the shortest sequence of mips instructions

Find the shortest sequence of MIPS instructions that extracts bits 16 down to 11 from register $t0 and uses the value of this field to replace bits 31 down to 26 in register $t1 without changing the other 26 bits of register $t1.

  Distinguishing web pages or web servers for task

Distinguish between any Web pages or Web servers you would use for this task.

  Validate the pairing of parenthesis in an expression

You are to write two programs. One will validate palindromes; the other will validate the pairing of parenthesis in an expression. These programs must both use stacks. You can write either an array based stack, or a linked list to perform these ta..

  Write a bash shell script prompt user to enter first name

Write a Bash shell script named phone.bsh that prompts the user the to enter first or last or any portion of person's name, so that can be found the appropriate entry in the phone directory file.

  Explain one new concept learned about arrays

Explain one (1) new concept that you have learned about arrays and one (1) new concept that you have learned about loops as a result of reading the assigned article.

  Write down program which declares integer variables

Write down complete program which declares the integer variable, reads value from the keyboard into that variable, andwrites to standard output variable's value, twice the value.

  A police officer or investigator has sufficient cause

If a police officer or investigator has sufficient cause to support a search warrant, the prosecuting attorney might direct him or her to submit a(n) ???a. exhibitb. verdict

  Write program that asks user for initial

Write a program that asks a user for his/her first initial. Then ask the user to type 1,2 3, 4. When the user types 4 the program ends. When the user types in 1, 2, or 3 , the program displays the message.

  Write advantages of external css and internal css

Write down the advantages of external CSS compared to internal CSS? Describe conditions in which each is suitable type.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd