Question: 1.32 LAB: Nutritional information (classes/constructors) Given main, complete the Food Item Class (in file Fooditemjave) with constructors to initialize each food itern. The default constructor





1.32 LAB: Nutritional information (classes/constructors) Given main, complete the Food Item Class (in file Fooditemjave) with constructors to initialize each food itern. The default constructor should initialize the name to "None' and all other fields to 00 The second constructor should have four parameters (food name grams of fat, grams of carbohydrates, and grams of protein) and should assign each private field with the appropriate parameter value. Ex If the input is MEM 10.0 34.0 2.0 1.0 where M&M's is the food name, 100 is the grams at fat 34.0 is the grams of carbohydrates, 20 in the grams of protein, and 10 is the number of servings, the output is Nutritional information per te ving Note: Fat: 0.00 g Carbohydrates: 0.00 9 Protein: 0.00 Number of calories for 1.00 serving 0.00 Nutritional information par Being MARS att 10.00 Carbohydrates: 34.009 Proteint 2.000 Number of calories for 1.00 serving (n) 234.00 The first Fooditem above is initialized using the default constructor LAR ACTIVITY 1321. LAB Nutritional information (classes/constructors MOCROSS at 10.00 Cittbohydrater 34.00 Protein 2.009 Number of calories for 1.00 werving (1 234.00 The first Foodtem above is initialized using the default constructor ACTIVITY 132 LA Nutritional information classes/constructors) 4/10 File is marked read only Current file Nutritionalindojav - 1mport java.util.Scanner I public class Nutritional Info public static void main(Stringar Scanner sonno Scanner(System.in) Food foodFoodit String to see nesto: 1e double amountFoto.extDouble double countCarbs - Schote dute asuntProtein Sextube Food food Foodtiene, mentformounters, in): 15 16 double servings - screextDoo: 17 10 foodterin 13 11 Develop mode Submit mode Run your programs often as you like before submitting for grading Below type any needed input values in the first box then click Run program and observe the programuotout in the second box Enter program input (optional) your oude route the MacBook Air > GOD 15 30 e Nutritional information per serving of KRW Fat: 10.00 Carbohydratust 34.00 9 Protein 2.000 Number of calories for 1.00 serving) 234.00 The first Foodtem above is initialized using the default constructor 7155 UAB ACTIVITY 132.1: LAB: Nutritional information (classes/constructen) 4/10 File is marked as read only Current file Nutritional to je 11 double countCarbs nextDouble double countProtein extDouble I 14 Food to food now Foodtito, itat, amount Cart nochten 15 16 double undervingsschemextDouble 17 16 food.printino 19 System.out.print(ber of color for servir 2 userving ze fooditeltorderings 22 22 System.out.println(""); footprintInfo(): System.out.printre of calories for saving, Sarving foodtenetCatarischerving): Develop mode Submit mode Run your programas often as you'd like before butimitting for grading Below, type any needed input values in the first box, then click Run program and observe the programi output in the second box Enter program input (optional) If your code regreso provide the MacBOOKS Nutritional information per serving of MM Fat: 10.00 Carbohydrates: 34.00 9 Protein: 2.009 Number of calories for 1.00 serving (s. 234.00 The first Foodtem above is initiatized using the default constructor, LAB ACTIVITY 1.32.1; LAB. Nutritional information (classes/constructors) 4/10 Current file Fooditem.java 1 public class Foodton 2 private String none; 3 private double for I private double carti private double protein I TOOO Define defolt constructor 1000: Define second constructor with to inition 10 72 private les com fot. con protein 11 12 public String geho) return on: 1 15 16 puble double to 12 return fet; 3 Develop mode Submit mode Run your program as often as you'd before submitting for grading Below, type any needed input volues in the first box, then click Run program and observe the prograuis output in the second box Enter program input (optional) if your code required input vide them here MacBook A Protein 2.009 Number of calorien for 1.00 serving 234.00 The first Fooditem above is initialized using the default constructor 294581001172 LAR ACTIVITY 1.32.1: LAB: Nutritional information (classes/constructors) 4/10 Current file: Fooditemjava 19 20 21 22 public double getCarbs retium corbs 3 public double getProtein return protein 1 24 25 25 27 28 29 30 31 32 public double get calories(double numservings) / Colorie Formula double calories - Crot carbs protein Servings return calories 3 none SR public void print Info System.out.printlnutritional information de serving of System.out.printf Fat Kot): Southern Carbon Develop mode Submit mode Run your programas often as you'd like, before submitting for grading Below Type any needed input Values in the first box then click Run program and observe the program's output in the second bak Enter program input (optional) If your code requires Nutritional Java Output (shown below Run program Input (from above) MacBook Air Bylock catalog Helge M 1.52 Nonal information (classes/constructora) Carbonara Protein 2.00 G Number of stories for 1.00 serving tot 234.00 The first Fooditem above is initialized using the default constructor ACTIVITY 1321:LAB Nutritional information (classes/constructors) Current file Fooditom java 24 puble double petProtein retum protein 26 27 28 30 31 32 public double talorescuble Seringe // Colore forud double calories - fut + (cartes proteinervings return calories 3 1 polic void peintInfo System.out.printlnutritional informing of none; System.out.print FOREX foto System.out.print Cart 2, Coros) System.out.print Protein N.2 protero 36 37 AD Develop mode Submit mode Run your program as often as you'd like before submitting for grading Below.type any needed input values in the first box, then click Run program and observe the program is output in the second box Enter program Input (optional) if your code regula provide Nutritional Output (shown below Run program outrom above) MacBook
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
