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

Open Visual Studio on your PC and select to create a New Project , name the new

ID: 3674912 • Letter: O

Question

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 named loanAmount . (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 this return ((loanAmount*1.05)/loanTerm);

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

Explanation / Answer

Form1.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CarPayment
{
    public partial class Form1 : Form
    {
        int loanterm;
        double loanamount;
        double payment;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
          
            loanamount = Int32.Parse(textBox1.Text);
              
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
          
            loanterm = Int32.Parse(textBox2.Text);
        }

        private void button1_Click(object sender, EventArgs e)
        {
  
            payment = calculateCarPayment(loanamount, loanterm);
           // payment = (loanamount * 1.05) / loanterm;
            Console.WriteLine("Your monthly loan payment will be " + payment.ToString());
            button1.Text = "Your monthly loan payment will be" + payment.ToString();
        }
        double calculateCarPayment(double la, int lt)
        {
            return ((la * 1.05) / lt);
          
        }
    }
}

Design :-

Output :