be done.  You should only add one line of code. #include #include #include   using namespace std;   double colleg

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

The following code does not work.  What needs to be fixed?  Retype the code and clearly label what needs to be done.  You should only add one line of code.

#include <iostream>

#include <iomanip>

#include <cmath>

 

using namespace std;

 

double collegeFund(double payment, double interest, double years);

void calculateAndPrint(double payment, double interest, double years);

 

int main()

{

                    double futureValue;

                    double PMT;

                    double i;

                    double n = 18;

                    double annualIncome;

                    const double COLLEGE_TUITION = 10250 * 4;  //Cost per year to attend Texas A&M University.  Whoop!

 

 

                    cout << fixed << showpoint << setprecision(2);

 

                    cout << "Enter the amount you plan to invest each year: ";

                    cin >> PMT;

                    cout << endl;

 

                    cout << "Enter the estimated interest rate in decimal format: ";

                    cin >> i;

                    cout << endl;

 

                    futureValue = collegeFund(PMT, i, n);

 

                    cout << "If you invest $" << PMT << " for " << n << " years "

                                        << "with an interest rate of " << i * 100 << "%" << " then you will have $"

                                        << futureValue << " for your children's future college fund. \n" << endl;

 

                    if (futureValue >= COLLEGE_TUITION)

                                        cout << "Your child will have the necessary funds to attend any in-state college." << endl;

                    else

                    {

                                        cout << "Please enter your annual income: ";

                                        cin >> annualIncome;

                                        cout << endl;

                                        if (annualIncome > 50000)

                                                            cout << "Your child will have to work and/or borrow money for college.\n";

                                        else

                                                            cout << "Hopfully the difference will be made up by Pell grants.  Try to save more.\n\n";

 

                    }

 

                    calculateAndPrint(PMT, i, n);

 

 

                    system("pause");

                    return 0;

 

}

 

 

//Function to return yearly investment with accumulated interests in 18 years.

 

double collegeFund(double payment, double interest, double years)

{

                    

                    return payment * (pow((1 + interest), years) - 1) / interest;

                    

}

 

//Function to calculate and print out yearly investment with accumulated interest per year for 18 years.

 

void calculateAndPrint(double payment, double interest, double years)

{

                    cout << "As an incentive to save early, please note the accumulated principal plus interest each year.\n"

                                        << endl;

                   

                   

                    for (int i = 0; i < years ; i++)

                    {

                                       

                                        double FV;

                                        FV = payment * ((pow((1 + interest), (i+1)) - 1) / interest);

                                        interestPlusPrincipal[i] = FV;

                                        cout << "Year " << i + 1 << " $" << interestPlusPrincipal[i] << endl;

 

                    }                  

}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Types of Loop
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education