Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi, please help me with my homework question thank you! Attached is the question 9. Consider the class FoodItem below. class FoodItem friend ostreams operator>

Hi, please help me with my homework question thank you! Attached is the question

image text in transcribed
9. Consider the class FoodItem below. class FoodItem friend ostreams operator> (istreams, FoodItems) ; private: string name, description; double price, weightInkg; int daysToExpiry; public: FoodItem () = default; Implement the extraction operator function, such that when the following lines are executed : FoodItem fi; cin > > fi; the extraction operator function will prompt user to enter the food item's name, description, purchase price, weight (measured in kilograms) and no. of days to expiry, to initialize its own FoodItem argument's name, description, price, weightInkg and daysToExpiry respectively. The entire Fooditem object should be thrown (as an exception object), if any of the following condition(s) is true : the Fooditem's "days to expiry" (entered by user) is negative, or exceeds 2 digits the Fooditem's price and/or weight (entered by user) is negative, or exceeds 1000.00 any string variables storing name, description (entered by user) is an empty string

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

List five advantages of the finite element method?

Answered: 1 week ago