Related questions
/*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
Step by stepSolved in 2 steps with 1 images
- Write a program that prompts the user to input the length of a string as an integer, followed by the string and outputs the string in uppercase letters using dynamic arrays.arrow_forwardNeed help writing this java code, it has three objectives: to process strings to compare, search, sort, and verify location of specific pattern to output result via interface Description Write a Java program to read a text file (command line input for file name), process the text file and perform the following. Print the total number of words in the file. (When using java_test.txt, I calculate the number of words, including number, as 254.) Print the total number of different words (case sensitive, meaning "We" and "we" are two different words) in the file. (When using java_test.txt, I calculate the number of different words, including number, as 168.) Print all words in ascending order (based on the ASCII code) without duplication. Write a pattern match method to find the location(s) of a specific word. This method should return all line number(s) and location(s) of the word(s) found in the file. Print all line(s) with line number(s) where the word is found by invoking the method...arrow_forwardI could really use some help with a problem I got for coding. A screenshot showing an example would help.arrow_forward
- In Python IDLE: How would I write a function for the problem in the attached image?arrow_forwardUsing Python Spark Read each text files that are provided and convert each words in the file to lower case. (I cannot upload the text files so if you find a folder online with 15 text documents that would work) Create a list with words from each text files. Remove stop words from each list and get the final list of words for each text files. (The list of stop words are provided in stopwords.txt)arrow_forwardJavascript Use a for/of loop to iterate over the array of students. For each student, use a template literal to print out their name, age, and major in a formatted string. (e.g. John is 18 years old and is studying Computer Science.) Within the template literal, use object dot notation to access the name, age, and major properties of the student object. Use a console.log() to print out the formatted string for each student. Test the code by running it and verifying that it prints out the details of each student in a formatted string.============================================================================== const students = [ { name: "John", age: 18, major: "Computer Science" }, { name: "Newton", age: 19, major: "Mathematics" }, { name: "Barry", age: 20, major: "Physics" }, ]; // Iterate through the array of objects students using for/of // Print a message to the console that includes the student's name, age, and major // Example: John is 18 years old and...arrow_forward
- Text book imageComputer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONText book imageComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceText book imageNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Text book imageConcepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningText book imagePrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationText book imageSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY