[Solved]72 Write Java Program Called Create Excel Spreadsheet Create Class Called Food Represent L Q37233086
7.2 Write a Java program called to create an Excelspreadsheet
- Create a class called Food to represent a Lunch food item.Fields include name, calories, carbs
- In a main method (of a different class), ask the user “How manythings are you going to eat for lunch?”.
- Loop through each food item and prompt the user to enter thename, calories, and grams of carbs for that food item. Create aFood object with this data, and store each Food object in anArrayList
- Create a method called printLunch(), that will take anArrayList of Food objects as an argument and create an Excelspreadsheet. This method should loop through the ArrayList andwrite the data to a file called lunch.csv (CSVstands for Coma Separated Values)
- The data should be printed in this format below. Be sure toinclude a header as the first line of code written the the file,and a total row at the end. You will see that every row will be anew row in the Excel spreadsheet, and every coma will create a newcolumn.
- After collecting all the food data in your main method, passthe ArrayList to the printLunch () method.
Hint: To append to a file, check outhttps://www.youtube.com/watch?v=mkqbbkBqOaU
Example lunch.csv file (You should be able toopen this file in Excel, but in Notepad it will look just likethis)
Name, Calories, Carbs
Pizza, 1800, 46.3
Salad, 355, 6.4
Soda, 200, 12.1
Total, 2355, 64.8
Expert Answer
Answer to 7.2 Write a Java program called to create an Excel spreadsheet Create a class called Food to represent a Lunch food item… . . .
OR

