Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

More Books

Students also viewed these Databases questions