Your CreditCard class must have the following instance data:
The class must have the following public instance methods:
Charges: $340.00 Interest: $ 68.00 New Balance: $408.00Note that your string can contain the escape sequence for new line (\n).
The CreditCard class should also have the following static method:
Some examples:
Sum of digits in even positions: 3 + 2 + 6 + 0 + 9 + 4 + 0 + 1 = 25 Number of digits > 4 in even positons: 2 (the 6 and 9) Sum of digits in odd positions: 1 + 5 + 0 + 1 + 6 + 3 + 0 + 2 = 18 25 * 2 + 2 + 18 = 70 70 is divisible by 10 so the number is valid.
Sum of digits in even positions: 4 + 2 + 0 + 1 + 3 + 5 + 7 + 9 = 31 Number of digits > 4 in even positions: 3 (the 5, 7, and 9) Sum of digits in odd positions: 1 + 8 + 0 + 2 + 4 + 6 + 8 + 3 = 32 31 * 2 + 3 + 32 = 97 which is not divisible by 10 so the number is not valid
NOTE: You will need to use methods in the String class and wrapper classes in this method. You could break this method up into some private support methods.
get the credit card number (call the method validCCNum to do this) if the number is not valid display a message telling the user he/she is suspected of credit card fraud (or something equally scary) else // the number is valid { read in the credit limit and annual interest rate instantiate a CreditCard object do { let the user charge things (call the method makeCharges to do this) let the user make a payment (call the method makePayment to do this) } while the user wants to continue }The three support methods used by main are as follows:
NOTE: As usual use good programming style and good programming habits!!! Do not try to type everything in at once -- do the program incrementally. Use good variable names and proper indentation and white space. Be sure to include brief documentation for each method you use!
Hand In: A printout of each file (CreditCard.java and class that uses it) and tar your directory containing the program and email it to me.