Question: in jAVA Parent Class: Food Write a parent class called Food. A food is described by a name, the number of grams of sugar (
in jAVA Parent Class: Food
Write a parent class called Food. A food is described by a name, the number of grams of sugar as a whole number and the number of grams of sodium as a whole number
Core Class Components points
For the Food class, write:
the complete class header
the instance data variables
a constructor that sets the instance data variables based on parameters
getters and setters; use validity checking on the parameters where appropriate
a toString method that returns a text representation of a Food object that includes all three characteristics of the food
ClassSpecific Method points
Write a method that calculates what percent of the daily recommended amount of sugar is contained in a food. The daily recommended amount might change, so the method takes in the daily allowance and then calculates the percentage.
For example, let's say a food had grams of sugar. If the daily allowance was grams, the percent would be For that same food, if the daily allowance was grams, the percent would be
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
