The Grocery Store Transactions from December 4, 2021 3 Transaction Time Item Purchased Item Type Price Special Feature(s) 5 2021-12-04T00:40:51.487813040 6 2021-12-04T00:43:06.771753742 7 2021-12-04T01:01:41.341483336 8 2021-12-04T01:02:46.638450949 9 2021-12-84T01:08:46.808325632 "Newspaper" "Oreo" notEdible edible edible 73.56 UK 17.73 2022-08-22 2022-11-18 Italy Colombia "Candy" 20.42 15.14 "Hat" notEdible "Glass" notEdible 65.69 18 2021-12-84T01:09:24.953023986 "Oreo" edible 28.78 2022-84-27 "Mango" "pierogi" "Diapers" 11 2021-12-84T01:09:52.128081202 edibleFresh 14.64 2021-12-09 false 12 2021-12-84T01:15:01.847845428 edibleFresh 3.91 2021-12-67 true notEdible edible 13 2021-12-04T01:17:30.56ee77513 10.56 Colombia 14 2021-12-04T01:22:12.94229794e "Avocado" 11.98 2022-10-15 "Quaker" "Paper" edible notEdible 20.83 15 2021-12-04T01:35:16.382730767 16 2021-12-e4T01:57:42.918e35437 2022-02-03 83.85 USA notEdible 17 2021-12-84T02:03:32.605e08426 18 2021-12-84T02:08:00.934216598 19 2021-12-04T02:23:15.077889130 "Cleaner" 22.50 Peru "Oreo" edible 3.02 2022-06-22 "Jar" notEdible 70.21 USA 20 2021-12-e4T02:24:22.556993059 "Noodles" edible 14.82 2022-07-02 "Toy" notEdible edibleFresh edibleFresh 21 2021-12-84T02:34:34.855275829 90.75 Canada 22 2021-12-04T02:46:48.185576012 "pierogi" "Yogurt" 26.34 2021-12-09 false 23 2021-12-4T02:50:11.409913162 7.75 2021-12-11 false 24 2021-12-64T03:05:56.882802019 "Hat" notEdible 37.96 Italy 25 2021-12-04T03:06:59.893934447 "Juice" edibleFresh 23.14 2021-12-09 false "Toy" notEdible edible 26 2021-12-094T03:07:22.102619054 90.25 Ireland 27 2021-12-04T03:12:38.523779058 "Noodles" 20.88 2022-02-16 28 2021-12-0e4T03:14:41.100756237 29 2021-12-84T03:16:42.194111916 "Chips" "Sandwich" edible edible e0.04 2022-11-20 12.11 2022-09-03 30 2021-12-84T03:28:24.808788824 "Gloves" notEdible 88.75 Peru edible edible 31 2021-12-84T03:36:23.804043325 "Twix" 25.14 2022-07-10 32 2021-12-04T03:37:28.668535052 "Soup" 19.57 2022-05-10 33 2021-12-04T03:42:00.049457327 "Coffee" edible 17.96 2022-06-65 34 2021-12-94T03:45:04.461678887 "Ham" edibleFresh 16.09 2021-12-10 false "Lemon" "Ocea" edibleFresh 35 2021-12-04T03:47:08.292566935 26 2021-12-04TA3:47-12 271032745 11.31 2021-12-06 2021-12- ae true adihle 18 11
/*TASK 5. Implement part 1 of the report. You need to read data from input.txt file, store it into array of items (called items) and write it in a formatted form to the output file. Code, debug and present it in the best possible format.
Hint: It might be helpful to format the String coming from toString( ) method using String.format( ) method, which works similar to System.out.prinf.
Hint2: You might have to close and delete existing output .doc or .txt file from its folder *
public class YourUserName_hw7 {
static Item [ ] items = new Item [200];//an array of Items
static EdibleItem [ ] edibleItems;//an array of Edible Items
static int countEdibleitems = 0;//count edible items
static String pageHeader; //save the header
//main( ) method runs the program
public static void main(String[ ] args) throws FileNotFoundException {
double sum = 0, average = 0;
//Optional - create a new input file
//CreateInput.createInputFile( );
//call the method to read data from input.txt and store in the array of Items
readInputFile( );
//find the total revenue and the average price for this day
//create an output file
java.io.File file = new java.io.File(LocalDate.now( ).toString( )+"_yourusername_hw7_report.doc");
java.io.PrintWriter output = new java.io.PrintWriter(file);//you can rename later
//Part 1: lists all items sold within the December 4, 2021 by the timestamp
output.print("This report prepared on " + LocalDate.now( ) + " by yourusername, CPS*2231*xx\n\n");
//Print the header row of the data
//Print all items into the file (.txt or .doc)
//Display money total and the average price at the end of Part 1
The image is data from the input.txt file
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images