(Solved) : Using C Following Files Include Utensilshpp Include Include Int Main Std String Name Std S Q42720939 . . .

Using C++, and the following files:

#include “utensils.hpp”
#include <iomanip>
#include <iostream>

int main() {
std::string name;
std::string color;
double mass;
double size;
double bite_size;

std::cout << “Please enter the name of a food item:”;
std::getline(std::cin, name);
std::cout << “Please enter the mass of the food item:”;
std::cin >> mass;
// Create a Food object and pass the user’s input to theconstructor

std::cout << “Please enter the size of the spoon: “;
std::cin >> size;
std::cout << “Please enter the color of the spoon: “;
std::cin.ignore();
std::getline(std::cin, color);
std::cout << “Please enter your bite size using the spoon:”;
std::cin >> bite_size;
// Create a Spoon object and pass the user’s input to theconstructor

std::cout << “Food before being eaten:n”;
// Call the food object’s print member function

std::cout << “Food after spoon used:n”;
// Call the spoon object’s use function and pass your food objectas the
// argument

// Call the food object’s print member function again
return 0;
}

main.cpp Initial commit 12 minutes ago 2 utensils.cpp Initial commit 12 minutes ago utensils.hpp Initial commit 12 minutes ag

Other instructions Complete the main function as described. Place your classes in utensils.hpp . Member functions that take m

main.cpp Initial commit 12 minutes ago 2 utensils.cpp Initial commit 12 minutes ago utensils.hpp Initial commit 12 minutes ago BE README.md Utensil classes This program uses three classes: Utensil , Spoon, and Food . Utensil class Create a Utensil class with two data members: double size, and std::string color_ . Create a default constructor for Utensil that sets the size to 8.5 and its color to “silver”. Create a constructor that receives a double size and std::string color that sets size and color_ accordingly. Create accessor functions for both data members. Create a function use that receives a reference to a Food object, but does nothing to it (i.e., the member function’s body is empty). Spoon class Spoon inherits from Utensil and has an additional data member, a double bite_size_ . Create a default constructor for Spoon that sets the size to 6, color to silver and bite_size_ to 25. Create a nondefault constructor that receives a double size, an std::string color, and a double bite_size then assigns the values to the data member accordingly. Create a function use that receives a reference to a Food object and removes bite_size_ grams of mass from the object (i.e., eating the food). You will need to call that object’s eat member function and provide the appropriate arguments. Food class Create a Food class with two data members, an std::string name_ and double mass_ (in grams). Create a default constructor for Food that sets the name to “Apple Pie” and mass to 1000 . Create a constructor that receives an std::string name and double mass. Create a function eat that receives a double and subtracts it from mass_ if there is enough left. Otherwise, set the mass to 0 (can’t have a negative mass of an object). Create a function print that prints the food’s name and mass. Other instructions Complete the main function as described. Place your classes in utensils.hpp . Member functions that take more than five lines or use complex constructs should have their function prototype in utensils.hpp and implementation in utensils.cpp Sample Output: Please enter the name of a food item: Pumpkin Pie Please enter the mass of the food item: 1250 Please enter the size of the spoon: 5 Please enter the color of the spoon: gold Please enter your bite size using the spoon: 20 Food before being eaten: Pumpkin Pie 1250g Food after spoon used: Pumpkin Pie 1230g Show transcribed image text main.cpp Initial commit 12 minutes ago 2 utensils.cpp Initial commit 12 minutes ago utensils.hpp Initial commit 12 minutes ago BE README.md Utensil classes This program uses three classes: Utensil , Spoon, and Food . Utensil class Create a Utensil class with two data members: double size, and std::string color_ . Create a default constructor for Utensil that sets the size to 8.5 and its color to “silver”. Create a constructor that receives a double size and std::string color that sets size and color_ accordingly. Create accessor functions for both data members. Create a function use that receives a reference to a Food object, but does nothing to it (i.e., the member function’s body is empty). Spoon class Spoon inherits from Utensil and has an additional data member, a double bite_size_ . Create a default constructor for Spoon that sets the size to 6, color to silver and bite_size_ to 25. Create a nondefault constructor that receives a double size, an std::string color, and a double bite_size then assigns the values to the data member accordingly. Create a function use that receives a reference to a Food object and removes bite_size_ grams of mass from the object (i.e., eating the food). You will need to call that object’s eat member function and provide the appropriate arguments. Food class Create a Food class with two data members, an std::string name_ and double mass_ (in grams). Create a default constructor for Food that sets the name to “Apple Pie” and mass to 1000 . Create a constructor that receives an std::string name and double mass. Create a function eat that receives a double and subtracts it from mass_ if there is enough left. Otherwise, set the mass to 0 (can’t have a negative mass of an object). Create a function print that prints the food’s name and mass.
Other instructions Complete the main function as described. Place your classes in utensils.hpp . Member functions that take more than five lines or use complex constructs should have their function prototype in utensils.hpp and implementation in utensils.cpp Sample Output: Please enter the name of a food item: Pumpkin Pie Please enter the mass of the food item: 1250 Please enter the size of the spoon: 5 Please enter the color of the spoon: gold Please enter your bite size using the spoon: 20 Food before being eaten: Pumpkin Pie 1250g Food after spoon used: Pumpkin Pie 1230g

Expert Answer


Answer to Using C++, and the following files: #include “utensils.hpp” #include #include int main() { std::string name; std::string…

Leave a Comment

About

We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.

Quick Links

Browse Solutions

Place Order

About Us

× How can I help you?