From 498316afdc93da19eb4e753a0a88c99fa2ed28bb Mon Sep 17 00:00:00 2001 From: ericdouglas Date: Thu, 11 Jun 2015 05:56:53 -0300 Subject: [PATCH] Intro to CS -> Problem Set 01.01 - initial structure --- .../src/01-01-problem-set.js | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 computer-science/01-introduction-to-cs-and-programming-mit/src/01-01-problem-set.js diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/01-01-problem-set.js b/computer-science/01-introduction-to-cs-and-programming-mit/src/01-01-problem-set.js new file mode 100644 index 0000000..a5ac737 --- /dev/null +++ b/computer-science/01-introduction-to-cs-and-programming-mit/src/01-01-problem-set.js @@ -0,0 +1,50 @@ +/* +* +* Write a program to calculate the credit card balance after one year +* if a person only pays the minimum monthly payment required by the credit +* card company each month. +* +* Use raw_input() to ask for the following three floating point numbers: +* +* 1. the outstanding balance on the credit card +* 2. annual interest rate +* 3. minimum monthly payment rate +* +* For each month, print the minimum monthly payment, remaining balance, +* principle paid in the format shown in the test cases below. +* All numbers should be rounded to the nearest penny. Finally, print the result, +* which should include the total amount paid that year and the remaining balance. +* +* - Minimum monthly payment = Minimum monthly payment rate x Balance +* (Minimum monthly payment gets split into interest paid and principal paid) +* - Interest Paid = Annual interest rate / 12 months x Balance +* - Principal paid = Minimum monthly payment – Interest paid +* - Remaining balance = Balance – Principal paid +* +* http://bit.ly/1S6Tdys +* +*/ +var prompt = require( 'prompt' ); + +prompt.start(); +prompt.get([ + { + name : 'balance', + description : 'Outstanding balance' + }, + { + name : 'interest', + description : 'Annual interest rate' + }, + { + name : 'minimum', + description : 'Minimum monthly payment rate' + } +], function( err, results ) { + + var initialBalance = results.balance; + var interest = results.interest; + var minPayment = results.minimum; + + +});