Question: The first input to the program will be an integer number that indicates the number of ingredients. Following this, for each ingredient will be a

 The first input to the program will be an integer number

The first input to the program will be an integer number that indicates the number of ingredients. Following this, for each ingredient will be a line with the form: Ingredient_Name Price_Per_Ounce Is_Vegetarian Calories_per_Ounce Ingredient_Name is a single word token naming the ingredient. Price_Per_Ounce will be a real value indicating the cost of the ingredient in dollars per ounce. Is_Vegetarian will be the token "true" or "false" indicating whether the ingredient is vegetarian. Calories_Per_Ounce will be an integer indicating the caloric content of the ingredient per ounce. The program should count the number of vegetarian ingredients and report which ingredients provide the highest and lowest ratios of calories per dollar. The output should be formatted as follows: Number of vegetarian ingredients: Highest cals/$: where the angle bracketed items are placeholders for the actual answers. For example, the following input: Rice 0.12 true 37 Seaweed 2.95 true 113 Avocado 0.22 true 45 Salmon 1.77 false 48 Yellowtail 0.53 false 41 Eel 2.18 false 84 Should produce the following output: Number of vegetarian ingredients: 3 Highest cals/$: Rice Lowest cals/$: Salmon

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!