Question
Need this in JavaScript and PHP. The program for this Assessment will consist of three sections, each headed by the three-line comment below: //********************************************************* //****Assessment
Need this in JavaScript and PHP.
The program for this Assessment will consist of three sections, each headed by the three-line comment below:
//*********************************************************
//****Assessment 2 Program 4 Section X
//*********************************************************
(where X stands for the portion of the Assessment to follow.)
Assessment Requirements
Section 1:
Enter the comment with the section title as described above.
Create an arrayList named produceList.
ProduceList is used to hold the description and price of an item. Add the following data to the produce list:
bananas 0.59
grapes 2.99
apples 1.49
pears 1.39
lettuce 0.99
onions 0.79
potatoes 0.59
peaches 1.59
Write the data from produceList to a file called ProducePrice.
Write a function, named FileLineCount(), that returns an integer and accepts a string. Pass the function the file name. It shouldthen use a while loop to return the number of lines in a file. Hint: The function will be reading the file you just created above.
Call the function, FileLineCount(), and display its return value as the number of items in the file using the following format: "There are xx products in the file." Where xx is the number returned by FileLineCount().
Section 2:
Enter the comment with the section title as described above.
You will add four more items to the ProducePrice.txt file. They are as follows: peppers 0.99 celery 1.29 cabbage 0.79 tomatoes 1.19
Call the function, FileLineCount(), and display its return value as the number of items in the file using the following format: "There are xx products in the file." Where xx is the number returned by FileLineCount().
Section 3:
Enter the comment with the section title as described above.
Using a loop, read the contents of the file ProducePrice.txt into a new arraylist called producePrices.
After populating the producePrices arraylist, loop through it and print its contents, inserting a line number for each item.
Using the count property of the produce list, display the output in the following format: "There are xx products in the producePrices list."
EXPECTED OUTPUT
There are 8 products in the file.
There are 12 products in the file.
bananas 0.59
grapes 2.99
apples 1.49
pears 1.39
lettuce 0.99
onions 0.79
potatoes 0.59
peaches 1.59
peppers 0.99
celery 1.29
cabbage 0.79
tomatoes 1.19
There are 12 products in the producePrices list.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started