Can anyone do all of this? Got alot of points to give away. I need it in the nex
ID: 3539190 • Letter: C
Question
Can anyone do all of this? Got alot of points to give away. I need it in the next 5 or 6 hours. Please use comments in the code.
You are to write a C++ program to calculate the monthly car payment(s) for a customers. Do not use functions. Instead, make it a linear straight-line program. As much as possible you are to develop the code as modular building blocks. You are encouraged to use functional decomposition to design your program. You are to USE NO GLOBAL VARIABLES in your work. You should manually calculate some values to ensure that your program is working correctly.
In the following order, your overall program structure will consist of:
All input routines are to have informative and clear instructions for entering values. The input routines are to keep the user in the routine until an entry is valid. Your program should be well organized, use the suggested variable names, proper indentations, and appropriate comments. You are to use the concepts we have covered in the first seven chapters and are not to use capabilities found in chapters eight through twelve (such as functions, enums, arrays, structs, or classes). The input of all variables is via the keyboard (cin). The display routine is to use cout via the standard monitor.
price
Price of vehicle
float
downPayment
Down Payment
float
tradeIn
Trade in for vehicle
float
loanAmt
Loan Amount (calculated)
float
annualIntRate
Annual Interest Rate (fraction)
float
annualIntPercent
Annual Interest Rate (percent)
float
monIntRate
Monthly Interest Rate (fraction)
float
noMonths
Number of Monthly Payments (24, 36, 48 & 60)
int
monPayment
Monthly Payment
float
CODE SECTIONS
Main
Declarations and main
Get price
Input price of vehicle
Get interest rate
Input the annual interest rate as a decimal fraction.
Get down payment
Input down payment in dollars and cents.
Get tradein
Input trade in in dollars and cents
Calculate monthly payment
Calculate the monthly payment using the supplied equations
Display loan schedule
Display the pertinent loan data and calculation results.
Exit routine
Terminate program
Your programming manager has directed you to produce blocks of modular routines to perform different tasks.
Get price routine
You are to use a while loop to get the value from the keyboard. You are to edit the input value to ensure that the price value is greater than $50.00 and less than $50,000.00.
Get tradeIn routine
You are to use a while loop to get the value from the keyboard. You are to edit the input value to ensure that the tradeIn value is greater than or equal to zero and less than the price.
Get downPayment routine
You are to use a while loop to get the value from the keyboard. You are to edit the input value to ensure that the downPayment value is greater than or equal to zero and less than the price minus the trade in. .
Get annualIntRate routine
You are to use a while loop to get the value from the keyboard. The interest rate is to be entered as a decimal fraction. For example .06 would be entered rather than 6%. The annual interest rate must be greater than or equal to zero and be less than .50.
Calculate monPayment routine
You are to use the monPayment equation to calculate 4 monthly payment amounts. You are to calculate a monthly payment for 24, 36, 48, and 60 months.
Display loan schedule
You are to display the pertinent loan information. The report format and contents are shown below.
You are to align your columns (this example may not be aligned correctly) and display two places to the right of the decimal. You are given the following report example. The attached midterm grading guideline provides an example that you can use to verify your work.
Honest Dave%u2019s Used Cars
Vehicle price 99999.99
Trade in value 99999.99
Down payment 99999.99
---------
Loan amount 99999.99
Annual interest rate 99.99%
Monthly payment options
24 months 9999.99
36 9999.99
48 9999.99
60 9999.99
Data for verifying program calculation logic
Car price
16900
Trade In
2000
Down Payment
4000
Annual Interest Rate
7.5%
Months Monthly Payments
24 $490.50
36 339.06
48 263.55
60 218.41
Variable
Description
Data Type
price
Price of vehicle
float
downPayment
Down Payment
float
tradeIn
Trade in for vehicle
float
loanAmt
Loan Amount (calculated)
float
annualIntRate
Annual Interest Rate (fraction)
float
annualIntPercent
Annual Interest Rate (percent)
float
monIntRate
Monthly Interest Rate (fraction)
float
noMonths
Number of Monthly Payments (24, 36, 48 & 60)
int
monPayment
Monthly Payment
float
Explanation / Answer
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main() {
//Declarations and main
double price;
double downPayment;
double tradeIn;
double loanAmt;
double annualIntRate;
double annualIntPercent;
double monIntRate;
int noMonths;
double monPayment;
//Get price routine
while(true)
{
cout<<"Enter Car price: $";
cin>>price;
if(price>50 && price<50000)
break;
cout<<"Price entered should be greater than $50.00 and less than $50,000.00. Please try again"<<endl;
}
//Get tradeIn routine
while(true)
{
cout<<"Enter tradeIn value: $";
cin>>tradeIn;
if(tradeIn>=0 && tradeIn<price)
break;
cout<<"TradeIn value entered should be greater than or equal to zero and less than the price. Please try again"<<endl;
}
//Get downPayment routine
while(true)
{
cout<<"Enter downPayment value: $";
cin>>downPayment;
if(downPayment>=0 && downPayment<(price-tradeIn))
break;
cout<<"DownPayment value entered should be greater than or equal to zero and less than the price minus the trade in. Please try again"<<endl;
}
//Get annualIntRate routine
while(true)
{
cout<<"Enter Annual Interest Rate value as a decimal fraction: ";
cin>>annualIntRate;
if(annualIntRate>=0 && annualIntRate<0.50)
break;
cout<<"Annual Interest Rate value entered should be greater than or equal to zero and and be less than 0.50. Please try again"<<endl;
}
//Calculate monPayment routine
monIntRate = annualIntRate / 12.0;
annualIntPercent = annualIntRate * 100.0;
loanAmt = price - downPayment - tradeIn;
//output formatting
cout<<left;
cout<<setw(10)<<"Months";
cout<<"Monthly Payments"<<endl;
//calculating and outputting values
for( noMonths=24; noMonths<=60; noMonths = noMonths+12 )
{
monPayment = (loanAmt * monIntRate) / (1.0 - pow((1 + monIntRate),-noMonths));
cout.unsetf(ios::fixed | ios::scientific);
cout<<setw(10)<<noMonths;
cout<<fixed<<setprecision(2)<<monPayment<<endl;;
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.