2023 Java Programming Assignment 7 Files and Exceptions Problem Summary The credit card | Assignment Collections

Computer Science 2023 Java Program

2023 Java Programming Assignment 7 Files and Exceptions Problem Summary The credit card | Assignment Collections

Java Programming Assignment 7: Files and Exceptions

Problem Summary

The credit card company that you wrote the last program for would like you to expand the program to process a data file. They would like to have a program that will help them determine how much money they will earn in interest from their customers. The program will now handle all starting balances (even if they are under $500).

Each line of the data file will contain a starting balance, an annual interest rate, and a percent of the balance to pay off each month.

Sample data file lines would be:

1111.11 11.1 11

222.22 2 22

3333.33 13 33

You will write a program to:

 Read a number of months to calculate for, from the credit card company.

 Read data from a file, and determine the total interest paid by each customer for those months.

 Provide a report on the credit card company profits.

Since data will no longer be entered by the user, the program will implement exception handling to error check the values from the input data file.

NOTE: For an example of a Java program using file data, see Online Content section 13.11.

Program Requirements

Required Classes and Methods

Two separate classes will be required for this program.

1. The first class will be the same Credit Card Account class you defined for Java Assn 6.

For example: CreditCardAccount

The class will still have the following private properties (no changes):

 current balance

 annual interest rate (percentage – e.g. 12.5%)

 percent of current balance to pay each month (e.g. 10%)

Within the class:

 This program will use only the second constructor that has parameters for all three of the properties. Modify that constructor, as follows:

o Implement Exception Handling for all of the parameters

 If the starting balance read is invalid (i.e. not above $0)

 Throw an IllegalArgumentException

 Include a message to be passed back to the exception handler that explains why the interest rate is invalid, explains that the data from this line will be ignored, and includes all of the data items from the bad data line.

 

Unauthorized distribution (including uploading to any non-Regis Internet website) violates copyright law

 If the interest rate read is invalid (i.e. not between 3% and 25%)

 Throw an IllegalArgumentException

 Include a message to be passed back to the exception handler that explains why the interest rate is invalid, explains that the data from this line will be ignored, and includes all of the data items from the bad data line.

 If the pay down percent read is invalid (i.e. not between 0% and 33%)

 Throw an IllegalArgumentException

 Include a message to be passed back to the exception handler that explains why the paydown percent is invalid, explains that the data from this line will be ignored, and includes all of the data items from the bad data line.

 Otherwise, the constructor will initialize all of the data fields to the parameter values.

NOTE: All of these exceptions will be caught and processed by the method which calls the constructor.

 Modify the instance method to make a payment. This method will now:

o Record a payment for one month, doing all the same calculations as before, but without displaying anything.

o Return the amount of interest paid for the month.

 Modify the payoff instance method.

First rename the method to calcAccountInterest. This method will now calculate the interest paid on an account, over a specific number of months. Then modify the method code to:

o Have one parameter, a number of months to calculate interest for.

o Remove all code that displays anything.

o Change the loop to a for loop to calculate payment information each month, as follows:

 Call the method to make a payment

 Add the returned interest for the month to the total for the account.

Stop looping after making payments for the number of months specified by the parameter OR when the account balance reaches 0.

o Return the total interest paid on the credit card account for all the months specified.

2. The second class will be the main class that contains the main method.

This class will be different from Java Assn 6’s main class, so delete the PayoffComparison class.

This new main class will process the data file and display the results. Name it:

ProfitCalculator

Within the ProfitCalculator class:

 Define a static method to prompt for, read, and validate the number of months to calculate interest for, as follows:

o Prompt for a number of months greater than 0.

 

Unauthorized distribution (including uploading to any non-Regis Internet website) violates copyright law

o Error check, issuing error messages as necessary, and loop until a valid value is entered.

o Return a valid number of months.

 Create a main method to:

o Define a local constant containing the input data file name of accounts.txt

 Do not supply any pathnames with this file (just use accounts.txt ).

o Display a description to the user, describing what the program will do.

o In a loop that will repeat the rest of the method code:

 Call the static method to read the number of months to calculate the interest for

 Try to open the input text data file

 Catch any FileNotFoundException exceptions and display a message that includes the name of the file and that it could not be opened. Then exit the program.

 If the file opened (no exceptions):

 In a loop, until you reach the end of the file:

 Read three data items from one line of data in the text file.

 Try to create a new Credit Card Account object, using the data read from the file as the input parameters to the constructor.

o The try clause should include all the code that uses this object.

o Catch any IllegalArgumentException exceptions and display the message passed back. Then continue reading the next line of data.

 Call the calcAccountInterest instance method with the object and add

the returned interest for the account to the total interest earned by the credit card company.

 Close file.

 Display the number of accounts processed (valid lines read).

 Display the total interest earned by the company within the specified number of months

o Ask the user whether to repeat the program, using a different number of months for the interest calculations.

o Repeat the program until the user says they do not want to.

 

Unauthorized distribution (including uploading to any non-Regis Internet website) violates copyright law

Sample Run (using the 3 lines of sample data shown above):

WARNING: The objects, classes, and methods must be implemented exactly as specified above. If your program produces correct output, but you did not create and use the objects as specified, and implement the required classes and methods, you will lose a significant number of points.

3. The program must follow the CS210 Coding Standards from Content section 6.10.

Be sure to include the following comments:

o Comments at the top of each code file describing what the class does

 Include tags with the author’s name (i.e. your full name) and the version of the code (e.g. Java Assn 4, version 1.0)

o Comments at the top of each method, describing what the method does

 Include tags with names and descriptions of each parameter and return value.

Testing

You will need to create test data files to test your program. Your test data files should test every possible execution path within your code, including erroneous data which cause exceptions. Remember the data file should be named accounts.txt, and will need to be placed in the top level of your project directory, in order for your program to find it.

Before you submit your project, add your all files you used to test your program in the top level of your project directory (and add a number to the end of each file, if there are multiple test data files).

File examples: accounts1.txt

accounts2.txt (numbered, if multiple data files tested)

This program calculates how the interest earned by a credit card company, from all accounts, over a specific number of months.

Enter the number of months to calculate interest for: 6

***Invalid card interest 2.0% — data line: 222.22 2.0 22.0 ignored

Over the next 6 months, the total interest earned from 2 accounts will be $ 149.04

Run again with a different number of months (y/n)? y

Enter the number of months to calculate interest for: 12

***Invalid card interest 2.0% — data line: 222.22 2.0 22.0 ignored

Over the next 12 months, the total interest earned from 2 accounts will be $ 183.17

Run again with a different number of months (y/n)? n

Enter the number of months to calculate interest for: 12

***Invalid interest — line: 222.22 2.0 22.0 ignored

Over the next 12 months,

the total interest earned from 2 accounts will be $ 183.17

Run again with a different number of months (y/n)? n

 

o Warning: Only NetBeans export files will be accepted. Do not use any other kind of archive or zip utility.

Grading Programs will be graded using the rubric that is linked on the same assignment page as this file.

 

 

We give our students 100% satisfaction with their assignments, which is one of the most important reasons students prefer us to other helpers. Our professional group and planners have more than ten years of rich experience. The only reason is that we have successfully helped more than 100000 students with their assignments on our inception days. Our expert group has more than 2200 professionals in different topics, and that is not all; we get more than 300 jobs every day more than 90% of the assignment get the conversion for payment.

Place Order Now

#write essay #research paper #blog writing #article writing #academic writer #reflective paper #essay pro #types of essays #write my essay #reflective essay #paper writer #essay writing service #essay writer free #essay helper #write my paper #assignment writer #write my essay for me #write an essay for me #uk essay #thesis writer #dissertation writing services #writing a research paper #academic essay #dissertation help #easy essay #do my essay #paper writing service #buy essay #essay writing help #essay service #dissertation writing #online essay writer #write my paper for me #types of essay writing #essay writing website #write my essay for free #reflective report #type my essay #thesis writing services #write paper for me #research paper writing service #essay paper #professional essay writers #write my essay online #essay help online #write my research paper #dissertation writing help #websites that write papers for you for free #write my essay for me cheap #pay someone to write my paper #pay someone to write my research paper #Essaywriting #Academicwriting #Assignmenthelp #Nursingassignment #Nursinghomework #Psychologyassignment #Physicsassignment #Philosophyassignment #Religionassignment #History #Writing #writingtips #Students #universityassignment #onlinewriting #savvyessaywriters #onlineprowriters #assignmentcollection #excelsiorwriters #writinghub #study #exclusivewritings #myassignmentgeek #expertwriters #art #transcription #grammer #college #highschool #StudentsHelpingStudents #studentshirt #StudentShoe #StudentShoes #studentshoponline #studentshopping #studentshouse #StudentShoutout #studentshowcase2017 #StudentsHub #studentsieuczy #StudentsIn #studentsinberlin #studentsinbusiness #StudentsInDubai #studentsininternational