Using Java in Eclipse IDE /*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
Using Java in Eclipse IDE
/*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 3 steps