CIS170 Week2 Course Project CAR LOAN CALCULATOR

01 August, 2024 | 2 Min Read

Create a flowchart for a simplified version of your program.

Create a working version of it based on your flowchart. This should be a working program that accepts user input, does some calculation, and shows the results. It does not have to use conditional expressions, loops, and the like.

//Calculate a loan payment schedule

#include < iostream >

#include < iomanip > #include < cmath > using namespace std;

int main() {

int startingBalance = 0.0;     int loanLength = 0.0;     int interestRate = 0.0;     int monthlyPayment = 0.0;     int finalCost1 = 0.0;     int finalCost2 = 0.0;     int MontPropPayment = 0.0;     int intSav = 0.0;

cout \<\< fixed \<\< showpoint;

//User input loan balance     cout \<\< "Enter loan amount: ";     cin >> startingBalance;

//User input length of loan     cout \<\< "Enter length of loan: ";     cin >> loanLength;

//User input interest rate     cout \<\< "\nAnnual interest rate: ";     cin >> interestRate;

//User input Proposed Monthly Payment     cout \<\< "Proposed Payment: ";     cin >> MontPropPayment;

{         monthlyPayment = (startingBalance \*interestRate) / loanLength;         finalCost1 = startingBalance \* interestRate;         finalCost1 = startingBalance \* interestRate;

    finalCost2 =

        ((startingBalance / MontPropPayment) - loanLength) \* interestRate;         intSav = finalCost1 - finalCost2;         if (MontPropPayment > monthlyPayment)

    {             cout \<\< "Total owed will be " \<\< finalCost2 \<\< endl;             cout \<\< "your monthly payment is " \<\< MontPropPayment \<\< endl;             cout \<\< "Interest Saved is " \<\< intSav \<\< endl;

    }

    if (MontPropPayment > monthlyPayment);

    {             cout \<\< "Total owed will be " \<\< finalCost1 \<\< endl;             cout \<\< "your regular monthly payment is " \<\< monthlyPayment \<\< endl;

    }

}     return 0;

}

Related posts