Program #1

Say that you owe a balance on your credit card. The company charges you 1.5% per month on the unpaid balance. You have decided to stop using the card and to pay off the debt by making a monthly payment of N dollars a month.

Write a program that asks for the beginning balance and the monthly payment.

For each month, first calculate the interest due on the unpaid balance. Then calculate the new balance by adding the interest and subtracting the payment.

Display to the screen the balance and total payments so far for every succeeding month until the balance is paid. When the balance falls below the amount of the monthly payment, determine and display the final payment amount (including the interest) that will bring the balance to exactly zero.

Use a while loop to calculate and display the program output, and declare constants for all fixed values.

Sample run:

Enter the beginning balance:
1000

Enter the monthly payment:
100

Total
Month Payment Balance Payments
1 100.00 915.00 100.00
2 100.00 828.73 200.00
3 100.00 741.16 300.00
4 100.00 652.28 400.00
5 100.00 562.06 500.00
6 100.00 470.49 600.00
7 100.00 377.55 700.00
8 100.00 283.21 800.00
9 100.00 187.46 900.00
10 100.00 90.27 1000.00
11 91.62 0.00 1091.62

Note that the last payment should not be more than the amount owed.

Your program should include the following user-defined function:

  • A function to read and return the input of a floating point number (double) input from the user. The function requirements are:
    • The prompt for user input will be stored in a string constant and passed as an input argument to the function (example: "Enter the beginning balance: ").
    • The function will prompt the user for the input and then use a do-while loop to verify that the user input is positive and non-zero. If it is not, the function will issue an error message and then re-prompt the user to enter the number again, until a positive, non-zero value is entered.
    • Once a valid input has been entered, the value entered will be returned to the main function.

This function will be called twice within the program. The first time it is called, it will read and validate the beginning balance. The second time it is called it will read and validate the monthly payment.

Program #2

The Fibonacci series of integer numbers is formed by the following rule:

Each number is the SUM of the previous two numbers.

The Fibonacci series can begin with any two integers (positive or negative), so long as the next term is always the sum of the previous 2 numbers.

Interestingly, the sum of the first TEN members of a Fibonacci series is always ELEVEN times the value of the SEVENTH element in the sequence. Your program will prove this is true.

The program should first prompt the user for the first two numbers in the sequence. Accept any non-zero input (positive or negative).

Then, using a for loop, the program will generate each number in the series, keep a running sum, and determine the value of the seventh element. A function will be called each time the code loops, to generate the next number in the sequence.

Finally, the program should display a math equation showing 11 times the 7th element is equal to the sum of the first 10.

Sample Output: If the user enters 20 and 30 as the first 2 numbers:

The first 10 elements of a Fibonacci series
beginning with 20 and 30 are:
20 30 50 80 130 210 340 550 890 1440

The sum of the first 10 elements is: 3740
The seventh element is 340. 11 x 340 = 3740

Your program should include the following functions:

  • A function that takes the two adjacent elements in the series as input arguments and returns the value of the next element.
  • A function that takes the seventh element as an input argument, and returns the value of the seventh element times 11.
Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.