HW6: Final score

Description

You are going to write a program named FinalScore.java. The program reads a file with hw, midterm and final exam scores and then calculates the final score and write the results to another file.

Usage

The usage of the program is
java FinalScore inputFile outputFile
The program reads the scores from inputFile and then prints the results to outputFile.

Input file format

The format of score file is :
StudentID:hw1:hw2:hw3:hw4:hw5:hw6:midterm:exam
Example
score1.txt
402532413:5.5:9:9:9:8.5:9.5:37.5:98.5
521834001:7.5:8:7.5:7.5:3.5:4.5:33:55
902222333:8:10:10:10:10:10:28:78
818666444:2:2.5:3.2:5:5.5:2.5:21:44
222333444:10:10:10:10:10:10:40:100
111222333:5:5:5:5:5:5:30:80
222333521:6:8.5:2:3.5:4:7:39:88

Formula

The final score is then calculated by:
30% total HW score (10pt max each) + 25% midterm score (max 40 pts) + 45% exam score(max 100pts)
In other words, the final score is then calculated by
0.5*HW1 + 0.5*HW2 + 0.5*HW3 + 0.5*HW4 + 0.5*HW5 + 0.5*HW6 + 0.625*Midterm  + 0.45*Exam

Error

The data in the file may not be in correct format, example
score2.txt
402532413:5.5:9:9:9:8.5:9.5:37.5:98.5
521834001:7.5:8:7.5:7.5:3.5:4.5:33:55
902222333:8:10:10:10:10:10:28:78
818666444:2:2.5:3.2:5:5.5:2.5:21:44
502234458:2:a:a:a:b:3:11:22
102456456:9:9:9:9:9:8.5:40:88.5   
222333444:10:10:10:10:10:10:40:100
111222333:10:10:a:10:10:10:d:100
123456789:10:10:10:10:10:10:abcd:100
234524561:10:10:10
342215582:1:a:2:b
345645661:10:10:10:10:10:10:10:10:10:10:10:10:10:10:10
421222393:a:b:c:d:e:f:g:h:i:j:k:l:m:n
111222333:5:5:5:5:5:5:30:80
123123321:9:9:8.5:9:9:0:20:absent
222333521:6:8.5:2:3.5:4:7:39:88
here are some possible errors. You have to deal with all these errors. I assume all the numbers are within the correct range.

Sample Output

C:\hw6>java FinalScore
Usage: java inputfile outputfile

C:\hw6>java FinalScore xyz
Usage: java inputfile outputfile

C:\hw6>java FinalScore xyz abc def
Usage: java inputfile outputfile

C:\hw6>java FinalScore xyz abc
File xyz doesn't exist.

C:\hw6>java FinalScore score1.txt
Usage: java inputfile outputfile

C:\hw6>java FinalScore score1.txt out1.txt
The output is written to file out1.txt.

C:\hw6>java FinalScore score2.txt out2.txt
The output is written to file out2.txt.
Here is the content of:
out1.txt
402532413	93.0125
521834001	64.625
902222333	81.6
818666444	43.275000000000006
222333444	100.0
111222333	69.75
222333521	79.475

out2.txt
402532413	93.0125
521834001	64.625
902222333	81.6
818666444	43.275000000000006
502234458	The data for hw2 is not in correct format.
102456456	91.575
222333444	100.0
111222333	The data for hw3 is not in correct format.
123456789	The data for midterm is not in correct format.
234524561	Not enough data
342215582	Not enough data
345645661	Too many data.
421222393	Too many data.
111222333	69.75
123123321	The data for final exam is not in correct format.
222333521	79.475

What to submit

Call your source code file FinalScore.java. Put these files in your submit folder. Do not place this file inside another folder within your submit folder.

Remark

Solution

FinalScore.java