Use what you have learned about theScanner class, Constants, variables,print(ln),Strings, Decisions,Loops,Methods,andArrayListsto complete the project. **Please note: We will usingArrayListsonlyfor this project -notArrays.
Remember to watch theLecture Videosand additional videos in iCollege for examples on these topics and how tocommentyour program correctly. **Please do not use anyadvancedmaterial that is not in Chapters 1 - 7.
We will be completing our Programming Projects usingCode Check. Nothing is required by you to use this program. For each project, I will provide a URL that will take you to the project to complete. Once you have completed the coding project (you have unlimited attempts), you willdownload theReportfrom the Code Check website anduploadthis zipped file(s) to this Assignment folder. Inside this zipped file will be your completed code and your calculated score based on testing. I will view each of these and make adjustments and feedback as necessary. Iencourage you touse your IDE (jGrasp/Eclipse) to write the codeand thencopy and pasteover to Code Check so you will gain experience using an IDE.
Description of Project 5 Purpose:
In Project 5, we are going to learn how to read in data from a given file, store the data in an ArrayList, and traverse (go through) the ArrayList to calculate a value for output. We will continue to work with calculating a Final Grade as we have been in previous projects. However, in this project, the input files will contain theaveragesfor each category weight (Homework, Tests, Midterm, Final Exam). We will read in these averages from the file, add them to our ArrayList, and then traverse through the ArrayList to calculate a final grade for the given user. We will also learn how to handle Exceptions when reading and processing files.
For example, the averages.txt file contains this data:
85.9 78.2 89 94.3
It is "understood" that the values represent theaveragesof the user in this order: Homework, Tests, Midterm, Final Exam. We will read these values in and store in our ArrayList and then calculate the final grade given that each category weight is equal to 25% (all equal).
Please look at theDataAnalyzer.javaprogram inSection7.5for guidance on how to complete this project (DataAnaylzeruses Arrays, but we will substitute with ArrayLists).
The following are sample runs of the program to help you write your code and format your output:
Sample Output 1:
Please enter the file name:averages.txtYour final grade is: 86.85
----jGRASP: operation complete.
Sample Output 2:
Please enter the file name:averages2.txtYour final grade is: 91.70
----jGRASP: operation complete.
Sample Output 3:
Please enter the file name:grades.txtFile not found. Please enter the file name:averages.txtYour final grade is: 86.85
----jGRASP: operation complete.
Instructions Project 5:
This class willreada text file that contains 4 numerical averages for homework, tests, midterm, and final exam and calculate the final numeric grade. Each category is worth 25% of the final grade (weighted equally).
- Go to the following URL to complete the project:Project 5
- If using and IDE (jGrasp or Eclipse), create a new class file namedFinalGrade.java(optional) **You may wish to start in your IDE with all of thegivencode on the Code Check project site.
- Download and save the following text files for testing:averages.txtandaverages2.txt. Note: If using jGrasp, save the text files in the same file folder as your .java file. If using Eclipse, the text files go in your project folder, not the src folder:https://stackoverflow.com/questions/13674626/where-do-i-put-the-txt-file-that-i-want-to-read-in-java
- You will be filling in code everywhere you see the ellipses (. . .) in the code. Please follow the instructions and use the Sample Outputs to guide you.
- Write the Class comment and@authorand@versiontags
- In themainmethod (you may want to write your methods first and complete this last),
- Use awhileloop and try statement to read the file inputted by the user (see 7.5 p. 364)
- Create anArrayListto hold the list of grade averages that are returned from thereadFilemethod (see 6.8 p. 309 & 7.5 p. 364). **Note: We are usingArrayLists, not Arrays as in the example in 7.5.
- Create a variable to hold the return value of thecalculateFinalGrademethod.
- Output the final grade to two decimal places (see Sample Output for format).
- Fill in the correct Exceptions in thecatchstatements
- ThereadFilemethod has already been included for you - nothing additional needed.
- In thereadAverages()method:
- Write the method @tags
- Fill in the return type and parameter in the method header (see 7.5 p. 364)
- Create a newArrayListto hold the grade averages
- Use awhileloop to add averages to theArrayList"while there is a grade average in the file".
- Returnthe array list of grade averages.
- In thecalculateFinalGrade()method:
- Complete the method @tags.
- Create ONE variable to hold the category weight. *Note: In this project, all 4 categories will be weighted at25%(hw, tests, midterm, and final exam so we only need 1 variable).
- Create a variable to hold the final calculated grade and initialize to 0.
- Use anenhanced for loopto traverse the array and multiply the average by the weight and store in the final grade variable.
- Returnthe final grade.
- Testyour code using the given text files and correct any error messages or output formatting issues.
- Once you have everything correct, copy and paste your code to Code Check and upload.
Testing and Submitting
Once you have thoroughly tested your program, pleaseuploadthezippedfileonlyto thisCh. 6 & 7 Projectfolder in Assessments > Assignments.
You will be graded on:
- Neatness of code and use of proper indentation of 4 spaces, 8 spaces, etc. This is theCheckstylepart of yourReport.
- Commenting of code - including class comment, @author, @version, and code comments.This is theCheckstylepart of yourReport.
- Good use of constant and variablenames- they should bedescriptivenames and not individual characters or abbreviations. Ex. FINAL_COST or firstName.This is theCheckstylepart of yourReport.
- Output is correct and matches the Sample Output forall teststhat executed on your code in Code Check.This is theTest 1, Test 2, etc.part of yourReport.They must say "Pass".
- My visual inspection of your code. I will be checking for good variable and constant names and well as good indenting of code. Instructor reserves the right to make adjustments to the Code Check score based on inspection.
ALL DONE!! Great job!