Total Calculation
Objective
To practice using file I/O and output formatting.Task
Your task for this lab is to write a program that reads in a number of floating point values from a file, adds them together, and then prints out the total.
It must also print out the sales tax on the total at a 5.3% rate, and the final total of the original items + sales tax.
The input is from a file called "items.txt" and the output should be to a file called "total.txt".
Details
- Open the "items.txt" file.
- Read all of the values in a loop. You will need to use "hasNextDouble" for this.
- Keep a running total of the numbers in the file.
- Calculate the sub-total, tax, and final total.
- Write them out to the "total.txt" file.
- Print only two decimal points as these are monetary values.
Sample Files
Here is a sample items.txt file.
Here is the output that should appear in total.txt.