Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Homework: Credit Card Payment Calculator Table of Contents Instructions For this homework you will write a script to do some useful calculations for credit card

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Homework: Credit Card Payment Calculator Table of Contents Instructions For this homework you will write a script to do some useful calculations for credit card payments. Use the template provided below. At a minimum, your script should contain the functions get mia payaent(), iaterest_charged(), reasining.peyaents( ), and aain(), each of which is described below. Be sure to include a docstring in each function. Note: The resulting script is only an example of a remaining payments calculator and may not accurately reflect the same calculation methods as your personat credit cand. This seript should not be used to make financial decisions. get_min_payment() Parameters - balancet The total amount of the balance in an account that is left to pay (called the halance; you can assume this is a positive number) - fees: The fees associated with the credit card account (you can assume this is a positive integer: assign this parameter a default value of 0 ) Functionality 1. Compute the minimum credit card payment (ain_paynent). You should use the formula nin_payneat =((b+a)+f) where * b is the balance in the account - I is the percent of the balance that needs to be pald frepresented as a float where 2% is represented as 02). Make the constant value of this variable 02. Note: This is not the same thing as the NPR. - I is the amount of fees that will be pald per month. 2. Determine if the minimum payment that was computed using the formula is below 25 , If is is, we should set the minimum payment to 25 instead. Return this number. This function takes into account only balance, the minimum payment percentage, NOTE and fees. In the real world, minimum credit card payments may take more factors into account. interest_charged() Parameters - batence: The balance of the credit card (the amount in the account that has not been p.id off yet: you can assume this is a positive number) - apr: The annual APR (you can assume this is an integer between 0 and 100; for example, an APR of 5% would be expressed as 5 ) Functionality - Compute and return 1, the amount of interest accrued in the next payment according to the formula i =(a/y)bd, where - a is the APR expressed as a floating point numberfor example, an APR of 8\% would be .08) - y is the amount of days in a year - b is the balance in the account - dis the number of days in a billing cycle (expressed as an integer; you can safely assume that this will be 30 each time) remaining__payments() Parameters - batance: The balance of the credit card (that amount in the account that has not been paid off yet you can assume this is a positive number) - apr: The annual APR (you can assume this is an integer between 0 and 100; for example, an APR of 5% would be expressed as 5) - targetaoount: The target payment (the amount the user wants to pay per payment; you can assume this is a positive number, though it may be passed in as a none) - credit_tine: The credit line. The maximum amount of balance that an account holder can keep in their account. (you can assume this is a positive integer; defaults to 5000) - fees: The amount of fees that will be charged in addition to the minimum payment. fyou can assume this is a positive integer; defaults to 0 ) Functionality Compute and return the number of payments required to pay off the credit card balance. We will do this by simulating payments one at a time until the balance of the credit card reaches zero. We will be assuming fixed payments (in other words, assume that each payment is the same amount of money as the previous one) if and only if the user specified a target amount. Otherwise, the minimum payment will change according to the balance that remains in the account. Note that (in our application) credit card payments are broken down into two parts: an interest payment, and a part that pays down the balance of the account. The interest payment is calculated as described under interest charged(); the rest of the payment goes toward the balance of the credir card. NOTE This may not be interest is computed in the real world. For the purposen of our program we will assume that this is how it is computed. Along with computing the number of months(payments) required to pay off the balance, this funcrion should also compute how many months(payment periods) the balance spends over 75%, 50% and 25% of the maximum allowed credit line. Here is an algorithm for simulating payments until the credit card is paid off: - Initialize a counter with a value of zero; this counter represents the number of payments to be made. - Initialize 3 counters with a value of zero; these counters represent the number of months that the balnnce remains over 25%,50% and 75%, these counters are completely independent of one anothet and also independent of the counter that represents the number of payments to be made. - As long as the balance of the credit card is positive, repeat the following - Check if the target amount parameter was passed in as None, if it was passed in as None, use the get min paymento function to get the min payment based an the current balance and the fees. The payment amount will either be the minimum payment, or the target amount if it was passed in. - Use the interest charged0 function to determine what portion of the next payment will be interest. The total payment minus interest charged is the amount that will go toward paying the balance. Remember, these amounts will change with every payment. - If the payment towards the balance is negative, then this means that the balance increased even after payment. Given the parameter values, the balance will never be paid off. If this is the case, print a message to the user stating that the card balance cannot be paid off and quit the script. Otherwise, the program may continue. - Reduce the balance by the part of the payment that goes toward paying the balance. - Check if the balance is greater than 75% of the credit line, if so, increase the appropriate counter. - Check if the balance is greater than 500 of the credit line, if so, increase the appropriate counter. - Check if the balance is greater than 25% of the credit line, if so, increase the appropriate counter. - Increise the counter that counts the number of payments that have been performed. - When the balance of the is no longer positive, the value of the counter is the number of payments required. fetum the counters all together as a fuple. You can return multiple items at once from a function if you separate each item by a Note comma. The item returned will be a tuple containing the items that you returned. Each element in the tuple can be accessed referending iss respective index. main() Parameters - batance: The balance of the credit card (that amount in the account that has not beeb paid off yet: you can assume this is a positive number) - apr: The annual APR (you can assume this is an integer between 0 and 100; for example, an APR of 5% would be expressed as 5 ) - targetanount: The target payment (the amount the user wants to pay per payment; you can assume this is a positive number, defaults to None) - eredit. Line: The credir line. The maximum amount of balance that an account holder can keep in their account, (you can assame this is a positive integer, defaults to 5,000) - feest The amount of fees that will be charged in addition to the minimum payment. (you can assume this is a positive integer, defaults to 0 ) Functionality - Compute the recommended minimum payment using the set_ain_gsyatat () function - Display the recommended minimum payment to the user - Declare a variable named ptys_ainiman to False. This variable represents whether a user has chosen to pay the minimum payment each month or not. - If the user's target payment is None, set the pays_ninine to True. Otherwise, if the user's target payment is less than the minimum payment, print a mesage to the user (eg. Four target payment is less than the minimum payment for this credit card') and quit the programs otherwise: - Use reaaining_paynents() to figure out the total number of payments required Ohint we will assume that the beginning balance is the balance amount that was passed in). - If the user pays the minimum payment each time, display the number that represents the number of payments that need to be made to the user (e.8. If you pay the minimum payments each month, you will pay off the balance in \& total payments > payments:? replace the angle brackets with the appropriate values) - If the user does not pay the minimum payments, dirplay the number that represents the number of payments that need to be made to the user along with what the derired payment amount is fe.g. If you make payments of $ \& target payment , you will pay off the balance in payments ? replace the angle brackets with the appropriate values) - Return a string that is a message that will tell the user how many payments they will be above 25, 50 and 75 peroent thiresholds. NOTE Your returned string should mimic the stracture and content of the output provided in the example output below. Template * "Perforn credit card caleukations."** froa argparse laport ArqunentParser ieport sys a replace this coment with your inplenentation of get_ain_paynent ( ). 4 interest_charged(), reaaining payments(), and aaia() def parse args(args-1ist): " ITakes a list of strings from the coanand pronpt and passes then through as arguments Args: args.list (list) : the list of strings from the consand pronpt Returns: args (ArqumentPar ser) parser = ArgunentParser( ) parser, add argunent ('balance anount', type = float, help = 'The total anount of balance left on the credit account') parser. add_argunent('apr', type = int, help = 'The annual APR, should be an int between 1 and 180 ) parser, add_argunent('credit line', type = int, help = 'The maximun anount of: balance allowed on the credit line.") parser.add_argunent ( - _payment:", type = int. default = None, belp = 'The anount the user wants to pay per payment, should be a positive nunber') parser,add_argunent ('iffees", type in float, default =0, help = "The fees that are applied eonthly.' ) 7 parse and validate arguments args = parser.parse_args (args_list) if args.balance amount

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2016 Riva Del Garda Italy September 19 23 2016 Proceedings Part 3 Lnai 9853

Authors: Bettina Berendt ,Bjorn Bringmann ,Elisa Fromont ,Gemma Garriga ,Pauli Miettinen ,Nikolaj Tatti ,Volker Tresp

1st Edition

3319461303, 978-3319461304

More Books

Students also viewed these Databases questions