Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

***I must use the format that is listed in the scale project above*** ***This MU

ID: 3679237 • Letter: #

Question

***I must use the format that is listed in the scale project above***

***This MUST be done in Visual Studio 2010***

*It must use printf and scanf

*It cannot use cout

*It must use stdio.h

It must use stdafx.h

Thank you

Open Visual Studio on your PC and select to create a New Project, name the new project CarPayment, and set the Location to save to your flashdrive to your folder called MyProgramProjects.

Now, write a program that does the following:

Print a message to the screen "Welcome to our car loan payment program... "

Print a message to the screen "The interest rate of our car loans is 5 percent. "

Print a message to the screen "Enter the amount of money you need to borrow: "

Read that value in as a double and store it in a double variable namedloanAmount. (you will need to create this variable at the top of your main program)

Print a message to the screen "Enter the term of the loan in months- enter 36 or 48 or 60: "

Read that value in as an int and store it in an int variable named loanTerm. (you will need to create this variable at the top of your main program)

Now call the function calculateCarPayment and store the value that will be returned by this function in a double variable called payment, like this:payment=calculateCarPayment(loanAmount, loanTerm); (you will need to create this variable at the top of your main program)

Print a message to the screen ("Your monthly loan payment will be: %.2f", payment);

After your main program, you will need to write the code for the function calculateCarPayment. It will calculate the amount of the car payment then it will return this value back to the main program. this can be done in one line like thisreturn ((loanAmount*1.05)/loanTerm);

Don't forget to add a line at the very top: #include "stdafx.h" (needed for VisualStudio software). Also don't forget to include your function prototype at the top of the program.

Explanation / Answer

#include “stdafx.h”

#include<stdio.h> /* printf,scanf definitions */

/* Function prototype */

double calculateCarPayment(double, int);

int main(void)

{

            double payment,loanAmount;

            int loanTerm;

            printf("Welcome to our car loan payment program... ");

            printf(“The interest rate of our car loans is 5 percent. ");

            /* get values for loanAmount and loanTerm*/

            printf("Enter the amount of money you need to borrow: ");

            scanf(“%lf”,&loanAmount);

            printf("Enter the term of the loan in months- enter 36 or 48 or 60: ");

            scanf(“%d”,&loanTerm);

            /* call calculateCarPayment function and display result*/

            payment=calculateCarPayment(loanAmount, loanTerm);

            printf("Your monthly loan payment will be: %.2f", payment);

            return(0);

           

}

double calculateCarPayment(double loanAmount,int loanTerm)

{

            return ((loanAmount*1.05)/loanTerm);

}