question archive For this assignment, you'll build an application that calculates the car loan amortization (month by month breakdown for the life of the loan)

For this assignment, you'll build an application that calculates the car loan amortization (month by month breakdown for the life of the loan)

Subject:Computer SciencePrice: Bought3

For this assignment, you'll build an application that calculates the car loan amortization (month by month breakdown for the life of the loan). Prompt the user to enter in the amount of the car loan, the APR, and the car payment per month including interest. The final output of your program should break down the monthly output for the user with the final line showing the total amount paid, total interest paid, and the number of months it took to pay off the car.

Sample

If the user enters a car loan amount of 20,000 with an APR of 4.5 and monthly payment of 350, the output should look something like this. Note that formatting won't be graded very harshly here for spacing, but it's important to make sure you have the number values on each line as shown below and that you are formatting money values as currency (ahem... .ToString("C")).

Calculations from month to month will use what's known as simple interest to determine the interest charge each month. Here's a breakdown of how it's calculated and your task will be translating this all to C#:

Determine the monthly interest rate by dividing the APR entered by the user by 12. Then divide by 100 since this is a percent

4.5 / 12 / 100 = 0.00375

Calculate the interest for the current month using the current balance. Make sure you round this to 2 decimal places to prevent rounding errors from month to month (use Math.Round for this since you actually want to round the number value instead of just format it for display):

21000 * 0.00375 = 78.75

Calculate the principle paid for the current month by subtracting the interest from step 2 from the payment

350 - 78.75 = 271.25

Calculate the remaining balance by adding the interest to the previous balance and subtracting the payment

21000 + 78.75 - 350 = 20728.75

Repeat this until the balance gets down to 0

Most likely, there will be a special case in the last month where the total payment left doesn't match the balance + new interest. In that case, you'll need to adjust the amount paid as shown in this example

Keep track of the total amount paid and total interest to print on the final line.

This is the layout to follow

Use this as a layout

using System;

namespace carLone{

public class Program{

public static void Main(string[] args){

//add code

}

}

}

using System; 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 namespace Test { [AttributeUsage (AttributeTargets. All)] public class PointsAttribute : Attribute { public pointsAttribute(int points) { Points = points; } public int Points { get; } } } net5.0 this.Output.split(Environment. NewLine, StringSplitOptions. RemoveEmptyEntries); 36 [TestInitialize] public void InitializeTest() { // Redirect the console output this.consoleOutput = new StringWriter(); Console.SetOut(this.consoleOutput); // Configure the console input this. SetUpInput(string. Empty); } [TestCleanup] public void CleanupTest) this.consoleOutput.Dispose(); this.consoleInput. Dispose(); protected void SetupInput(string input) { this.consoleInput?. Dispose(); this.consoleInput = new StringReader(input); Console.SetIn(this.consoleInput); 61 protected void SetupInput (params object[] inputs) var input = string. Join (Environment. Newline, inputs); this.SetUpInput(input); 64 65 66 67 68 } using System.Linq; using ITSS131; using Microsoft.VisualStudio. TestTools.UnitTesting; namespace Test { [TestClass] public class UnitTest : TestBase { [TestMethod] [Points(10)] public void HasAtleast40utputLines) { this.SetUpInput(21000,4.5,350); Program.Main(null); Assert.IsTrue(this.OutputByLine.Length >= 4); } [TestMethod] [Points(10)] public void SampleMonth10DataMatches() { this.SetUpInput(21000,4.5,350); Program.Main(null); Assert.IsTrue(this.OutputByLine. Any(line => line.Contains("10") && line.Contains("$69.46") && line.Contains("$18,241.27")); } 28 [TestMethod] [Points(10)] public void SampleMonth55DataMatches() { this. SetUpInput(21000,4.5,350); Program.Main(null); 36 37 38 Assert. IsTrue (this.OutputByLine. Any(line => line.Contains("55") && line.Contains("$17.99") && line.Contains("$4,465.61")); 39 } 40 41 42 43 44 [TestMethod] [Points (15)] public void SampleListsTotalInterest() { this.SetUpInput(21000,4.5,350); Program.Main(null); Assert. Istrue(this.OutputByLine.Any(line => line.Contains("$2,834.63")); } 45 46 47 48 49 0 [TestMethod] [Points (15)] public void SampleListsTotalPayments() { this. SetUpInput(21000,4.5,350); Program.Main(null); Assert. IsTrue (this.OutputByLine. Any(line => line.Contains("$23,834.63")); } 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 [TestMethod] [Points(10)] public void Sample2Month10DataMatches() { this.SetUpInput(16000, 6.7,250); Program. Main(null); Assert. Istrue(this.OutputByLine. Any(line => line.Contains("10") && line.Contains("$81.98") && line.Contains("$14,352.37")); } [TestMethod] [Points(10)] public void Sample2Month55DataMatches) { this.SetUpInput(16000,6.7,250); Program.Main(null); Assert. Istrue(this.OutputByLine. Any(line => line.Contains ("55") && line.Contains("$32.98") && line.Contains("$5,689.74")); } 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 [TestMethod] [Points(10)] public void Sample2ListsTotalInterest() { this.SetUpInput(16000, 6.7,250); Program. Main(null); Assert. IsTrue (this.OutputByLine. Any(line => line.Contains("$3,852.24")); } [TestMethod] [Points(10)] public void Sample2ListsTotalPayments() { this.SetUpInput(16000,6.7,250); Program. Main(null); Assert.IsTrue (this.OutputByLine. Any(line => line.Contains("$19,852.24"));
 

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE