Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Create a program to calculate how many months it will take to pay off a credit card given current credit card balance, annual percentage

C++

Create a program to calculate how many months it will take to pay off a credit card given current credit card balance, annual percentage rate, the monthly payment amount. Add 10% to the monthly payment and recalculate the number of months. Report the results in a table. Use top down design modular design methodology

Input: Prompt for

  • the clients name

  • the current credit card balance

  • the Annual Percentage Rate (APR)

  • the amount of money you can be paid monthly.

Formula:

n = log10(1 (Ai/P))/log10(1 + i)

Where,

n = Number of Months to payoff credit card

A = Amount on credit card

i = Monthly Rate (APR / 12)

P = Monthly Payment Amount

Constraints:

  • Enter the APR as an integer. A 22% interest rate would be entered as 22. Have the program convert this to the correct rate: 0.22.

  • Display the payoff months as a whole number - fractional months dont make sense.

  • Use the literal MONTHS_IN_YEAR rather than 12 in formulas requiring the number of months (if you need any).

  • Keep the Input, Processing, and Output sections of your code separate, use modular hierarchical design.

  • Design functions to

  • prompt and read client name

  • prompt and read API

  • prompt and read monthly payments

  • prompt and read current credit card balance

  • calculate the number of months (using helper functions as needed)

  • display the results in a tabulated form.

  • Use the appropriate C++ libraries for the log() function. Select the appropriate log function

Testing and Verification

You are required to test your program thoroughly to make sure it meets all the specifications. You can construct various combinations of testing sequences for verification purposes. Here are the testing sequences that I will use to verify the correctness of your program. The first three result in successful output and the next three demonstrate that input validation is done and cause the program to return to main menu. This is interpreted to mean that that the program did not have a successful output for that test run. Your program should respond in the same way as given below: You need to include screenshots of the output of your program in response to the following six testing sequences.

You should also create similar test sequences to test other valid and invalid inputs to see if your program is behaving correctly.

This program will be menu driven it will repeatedly ask the user to enter data and will terminate when the user enters N. Please see the program output in the testing and verification section to get an idea of the menu and behavior.

  • Input Validation: You are expected to do simple input validation. Some C++ functions that can be helpful to for this purpose are

  1. cin.fail() - This function returns true when an input failure occurs. For example, if an integer is expected and a string is given, then this function would return true. Experiment by writing small test programs to see the behavior of this function under different input conditions.If cin fails, then the input buffer is kept in an error state.

  2. cin.clear() - is used to clear the error state of the buffer so that further processing of input can take place. This ensures that the input does not lead to an infinite loop of error message display.

  3. cin.ignore() - This function is used to ignore the rest of the line after the first instance of error that has occurred and it skips to or moves to the next line.

  4. cin.eof() - This function can be used to check end of file errors. This returns 1 if the program tried reading something but, the end of the file was reached.

  • You will need to include the iomanip library for output formatting. Use three decimal places of precision.

  • You will also need the strings library.

  • You will need to use basic C++ functions, so make sure to review the C++ programming guide for CISP301 review on this topic and refer to Chapter 6 of the textbook.

  • You will need to submit your design document (see the sample programming assignment document) and submit your code as per the submission guidelines.

  • You are required to test your program thoroughly and provide snapshots of evidence that your program passes the above tests successfully. You need to provide screenshot evidence of this as given above in the testing and verification section. Here are the six testing sequences that you are required to provide evidence for: The first three test that with given valid inputs, your program calculates and displays the output accurately as per specification. The next three sequences test if the program does input validation for balance, API and monthly payments respectively. In these last cases, when an invalid input is entered, the program should indicate an error and loop back to the main menu. The program should terminate when the user chooses to exit by entering n. Note that the program should not be case sensitive and accept both Y/N and and y /n.

  • Your main program will be called CreditCardPayOffMain.cpp and will consist of a single function call to the function creditCardPayOffMain().

  • All the functions will be defined in a file called CreditCardPayOffFunctions.cpp

  • All the function prototypes will be declared in a file called CreditCardHeader.h

  • Test your program thoroughly and submit verification with screenshots of evidence that your program has passed all the tests.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions

Question

What are the cultural/ethnic/religious traits of your key public?

Answered: 1 week ago