java program

gevfun44
timer Asked: Nov 7th, 2018

Question Description

Instructions:

Write a Java program called to create an Excel spreadsheet of your friends.

  1. Create a class called Food to represent a Thanksgiving food item. Fields include name, calories, carbs (1 point)
  2. In a main method, ask the user "How many foods are you going to eat for Thanksgiving?".
  3. Loop through each food item and prompt the user to enter their name, calories, and grams of carbs for that food item. Store that Food object in an ArrayList (1 point)
  4. Create a method called printThanksgivingDinner(), that will take an ArrayList of Food objects as an argument (1 point)
  5. After collecting all the food data, pass the ArrayList to the printThanksgivingDinner () method. This method should loop through the ArrayList and write the data to a file called thanksgiving.csv (CSV stands for Coma Separated Values) (1 point)
  6. The data should be printed in this format below. Be sure to include 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 a new row in the Excel spreadsheet, and every coma will create a new column. (2 point)

Example thanksgiving.csv file (You should be able to open this file in Excel)

Name, Calories, Carbs
Turkey, 200, 18.3
Mashed Potatoes, 300, 12.4
Corn, 100, 9.5
Total, 400, 30.2

User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

This question has not been answered.

Create a free account to get help with this and any other question!

Related Tags

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors