diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/01-02-bisection-method-problem-set.js b/computer-science/01-introduction-to-cs-and-programming-mit/src/01-02-bisection-method-problem-set.js new file mode 100644 index 0000000..b66e99f --- /dev/null +++ b/computer-science/01-introduction-to-cs-and-programming-mit/src/01-02-bisection-method-problem-set.js @@ -0,0 +1,49 @@ +/* +* +* Author: Eric Douglas +* Finished: +* +* Paying Debt Off In a Year - BISECTION METHOD +* +* - interest is compounded monthly according to the balance at +* the start of the month +* - monthly payment must be a multiple of $10 and is the same for all months +* - it is possible for the balance to become negative using this scheme +*/ + +var prompt = require( 'prompt' ); + +prompt.start(); +prompt.get([ + { + name : 'balance', + description : 'Enter the outstanding balance on your credit card' + }, + { + name : 'interest', + description : 'Enter the annual credit card interest rate as a decimal' + } +], function( err, results ) { + + // input variables + var balance = parseFloat( results.balance ); + var interest = parseFloat( results.interest ); + + // output variables + var parcel = 0; + var months = 0; + var paid = 0; + + // helper variables + var step = 0.01; + var min = 0; + var max = 0; + var guesses = 0; + + // Results + console.log( '======= RESULT ======='); + console.log( 'Monthly payment to pay off debt in 1 year:', parcel ); + console.log( 'Number of months needed:', months ); + console.log( 'Balance', paid ); + +}); diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/01-02-problem-set.js b/computer-science/01-introduction-to-cs-and-programming-mit/src/01-02-problem-set.js index 17ed780..accb929 100644 --- a/computer-science/01-introduction-to-cs-and-programming-mit/src/01-02-problem-set.js +++ b/computer-science/01-introduction-to-cs-and-programming-mit/src/01-02-problem-set.js @@ -1,7 +1,7 @@ /* * * Author: Eric Douglas -* Finished: +* Finished: 2015-06-21 * * Paying Debt Off In a Year *