can someone give me an example of Problem Set 2 paying of credit card debt?
hello?
yes this is the right one
so, as this question is, it seems like you just want a solution. The philosophy of the site is more about finding what your problem is, and solving it from there. What have you tried so far? what are you stuck on? do you have any pseudocode written?
well I wanted a solution because im having a hard time to formulating an actual quest to ask, do you want me to send the code ive already written?
yes, please that would help a lot. especially since i have long since deleted my solution for this problem (or at least hidden it from myself)
##OB = outstanding balance ##AIR = annual interest rate ##MMP = minimum monthly payments OB=int(raw_input("enter outstanding balance: ")) AIR=float(raw_input("enter interest rate(decimal): ")) MMP=float(raw_input("enter minimum monthly payment percent(decimal): ")) B=(OB*MMP) print B
well you have your initializations, now you need to iterate over each month of the year and perform the calculations described in the pset
wouldnt I need to use a loop to have it kept going over each month?
yes, you also need to initialize a variable for the total amount paid, since you need to print that at the end
would it be a good idea to define the formula for an interest compund formula and then use it in a loop? im having a problem with how to set up the syntax for that loop!
in pseudocode: ``` ## initalize total paid ## for each month of the year ## calculate Minimum monthly payment ## add this amount to the total paid variable ## print min monthly payment ## calculate Interest Paid ## print interest paid ## calculate Principal Paid ## print Principal paid ## print Remaining Balance ## print "RESULT" ## print remaining balance ## print total paid ```
that helps out alot thank you
welcome, if you need more help you can repost this question with a link to the original so that others can see what we did already. Good luck!
##OB = Outstanding Balance ##AIR = Annual Interest Rate ##MMPP = Minimum Monthly Payments Percentage ##MMP = Minimum Mnthly Payments ##IP = Interest Paid ##PP = Principal Paid ##RB = Remaining Balance OB=int(raw_input("Enter Outstanding Balance:")) AIR=float(raw_input("Enter Interest Rate(decimal):")) MMPP=float(raw_input("Enter Minimum Monthly Payment Percent(decimal):")) #i=1 #for float in i (i<=12): #i+=1 ##for each month of the year ##calculate minimum monthly payment ##??ad this amount to the total paid variable MMP = MMPP*OB ##print the min monthly payment print "Minimum Monthly Payment:",MMP ##calculate interest paid IP =(0.18/12.0)*OB ##Print Interest Paid print "Interest Paid:",IP ##Calculate Principal Paid, PP = Principal Paid PP = MMP-IP ##print Principal Paid print "Principal Paid:",PP ##Remaining Balanace RB = OB-PP ##print Remaining Balance print "Remaining Balance:",RB ##print total paid Ok this is what I have thus far, now my question is how do I initiate the loop and is that loop I have written down correct? also need to know how to label the month!
try either a 'while' loop, as in ``` month = 1 while month <= 12: ##do math described above print month month += 1 ``` or, even better in python, use 'range' ``` for month in range(1, 13): ##do math described above print month ``` notice that on each iteration the variable 'month' will take a value between 1 and 12, so printing it out on each iteration gives the month we are doing calculations for
thanks again!
Join our real-time social learning platform and learn together with your friends!