Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

Question about PS1b (Intro to CS spring 2011): 1) What is the decrementing function here? I am confused 2) If balance was 1200 to start with, would newBalance be 1208 after the first loop? If someone could walk through this problem in words using an example balance I would really appreciate it.

MIT 6.00 Intro Computer Science (OCW)
See more answers at brainly.com
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Join Brainly to access

this expert answer

SEE EXPERT ANSWER

To see the expert answer you'll need to create a free account at Brainly

What you're solving for here is "what monthly payment (in multiples of 10) do you need to pay off the balance within 12 months". Here's an example run of the program: Enter the outstanding balance on your credit card: 280 Enter the annual credit card interest rate as a decimal: .2 Month: 1 balance: 275.0 monthlyPayment: 10 Month: 2 balance: 269.0 monthlyPayment: 10 Month: 3 balance: 264.0 monthlyPayment: 10 Month: 4 balance: 258.0 monthlyPayment: 10 Month: 5 balance: 252.0 monthlyPayment: 10 Month: 6 balance: 247.0 monthlyPayment: 10 Month: 7 balance: 241.0 monthlyPayment: 10 Month: 8 balance: 235.0 monthlyPayment: 10 Month: 9 balance: 229.0 monthlyPayment: 10 Month: 10 balance: 222.0 monthlyPayment: 10 Month: 11 balance: 216.0 monthlyPayment: 10 Month: 12 balance: 210.0 monthlyPayment: 10 Month: 1 balance: 265.0 monthlyPayment: 20 Month: 2 balance: 249.0 monthlyPayment: 20 Month: 3 balance: 233.0 monthlyPayment: 20 Month: 4 balance: 217.0 monthlyPayment: 20 Month: 5 balance: 201.0 monthlyPayment: 20 Month: 6 balance: 184.0 monthlyPayment: 20 Month: 7 balance: 167.0 monthlyPayment: 20 Month: 8 balance: 150.0 monthlyPayment: 20 Month: 9 balance: 132.0 monthlyPayment: 20 Month: 10 balance: 115.0 monthlyPayment: 20 Month: 11 balance: 97.0 monthlyPayment: 20 Month: 12 balance: 78.0 monthlyPayment: 20 Month: 1 balance: 255.0 monthlyPayment: 30 Month: 2 balance: 229.0 monthlyPayment: 30 Month: 3 balance: 203.0 monthlyPayment: 30 Month: 4 balance: 176.0 monthlyPayment: 30 Month: 5 balance: 149.0 monthlyPayment: 30 Month: 6 balance: 122.0 monthlyPayment: 30 Month: 7 balance: 94.0 monthlyPayment: 30 Month: 8 balance: 65.0 monthlyPayment: 30 Month: 9 balance: 36.0 monthlyPayment: 30 Month: 10 balance: 7.0 monthlyPayment: 30 Month: 11 balance: -23.0 monthlyPayment: 30 RESULT Monthly payment to pay off debt in 1 year: 30 Number of months needed: 11 Balance: -23.09 You'll notice it starts the monthly payment at 10. Then runs through all 12 months making a payment each month. After each payment, it checks to see if it's paid off. Because it doesn't get paid off within a year at 10/month, it adds 10 (resulting in a monthly payment of 20) and runs through all 12 months again. Checking, of course, every month to see if it's paid in full. It didn't get paid entirely at 20/month so it adds another 10 and runs through the loop to check 30/month ... when it gets to month 11 it determines that everything is paid! At that point, it's solved ... for these input values, it takes 11 months at 30/month to pay it off in under a year. An important note: When you're subtracting the current month's payment from the total each month, remember to ALSO add in the interest for that month at the same time.
Roaming Blue, That is exactly what I was looking for. I was having trouble seeing the sequence of the loops. Now I understand the answer to the problem! Thank you very much for your detailed response. Regards, Tyler
http://dpaste.com/788942/

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

@tcc8m Anytime mate, happy coding.

Not the answer you are looking for?

Search for more explanations.

Ask your own question