Question

d. Fill in the underlines below to complete the definition of the default constructor of the class foodType so that the private member variables are initialized to "", 0, 0.0, 0, 0.0, 0.0, respectively. Answer: foodType { set } e. Fill in the underlines below to complete the definition of the constructor with parameters of the class foodType so that the private member variables are initialized according to the parameters. The values of the int and double instance variables must be nonnegative Answer: foodType (string s, int c, double f, int su, double cr, double p) { } f. Fill in the underlines below to write a C++ statement that prints the value of the object fruit2. Answer: fruit2

          d. Fill in the underlines below to complete the definition of the default constructor of the class
foodType so that the private member variables are initialized to "", 0, 0.0, 0, 0.0, 0.0, respectively.
Answer:
foodType
{
set
}
e. Fill in the underlines below to complete the definition of the constructor with parameters of the
class foodType so that the private member variables are initialized according to the parameters. The
values of the int and double instance variables must be nonnegative
Answer:
foodType
(string s, int c, double f, int su,
double cr, double p)
{
}
f. Fill in the underlines below to write a C++ statement that prints the value of the object fruit2.
Answer:
fruit2
        
Show more…
d. Fill in the underlines below to complete the definition of the default constructor of the class
foodType so that the private member variables are initialized to "", 0, 0.0, 0, 0.0, 0.0, respectively.
Answer:
foodType

set

e. Fill in the underlines below to complete the definition of the constructor with parameters of the
class foodType so that the private member variables are initialized according to the parameters. The
values of the int and double instance variables must be nonnegative
Answer:
foodType
(string s, int c, double f, int su,
double cr, double p)


f. Fill in the underlines below to write a C++ statement that prints the value of the object fruit2.
Answer:
fruit2

Added by Jessica M.

Close

Computer Science and Information Technology
Computer Science and Information Technology
Trishna Knowledge Systems 2018 Edition
AceChat toggle button
Close icon
Ace pointing down

Please give Ace some feedback

Your feedback will help us improve your experience

Thumb up icon Thumb down icon
Thanks for your feedback!
Profile picture
d. Fill in the underlines below to complete the definition of the default constructor of the class foodType so that the private member variables are initialized to 0, 0, 0.0, 0, 0.0, 0.0, respectively. Answer: foodType() { set("", 0, 0.0, 0, 0.0, 0.0); } e. Fill in the underlines below to complete the definition of the constructor with parameters of the class foodType so that the private member variables are initialized according to the parameters. The values of the int and double instance variables must be nonnegative. Answer: foodType(string s, int c, double f, int su, double cr, double p) { set(s, c, f, su, cr, p); } f. Fill in the underlines below to write a C++ statement that prints the value of the object fruit2. Answer: cout << fruit2; d. Fill in the underlines below to complete the definition of the default constructor of the class foodType so that the private member variables are initialized to 0, 0, 0.0, 0, 0.0, 0.0, respectively. Answer: foodType() { set("", 0, 0.0, 0, 0.0, 0.0); } Fill in the underlines below to complete the definition of the constructor with parameters of the class foodType so that the private member variables are initialized according to the parameters. The values of the int and double instance variables must be nonnegative Answer: foodType(string s, int c, double f, int su, double cr, double p) { set(s, c, f, su, cr, p); } f. Fill in the underlines below to write a C++ statement that prints the value of the object fruit Answer: cout << fruit2;
Close icon
Play audio
Feedback
Powered by NumerAI
*

Labs

-

Want to see this concept in action?

NEW

Explore this concept interactively to see how it behaves as you change inputs.

View Labs

*

Key Concepts

-
Key Concept
Premium Feature
Explore the core concept behind this problem.
Play button
Key Concept
Premium Feature
Explore the core concept behind this problem.
Your browser does not support the video tag.

*

Recommended Videos

-
519-lab-nutritional-information-classesconstructors-given-main-complete-the-fooditem-class-in-file-fooditemjava-with-constructors-to-initialize-each-food-item-the-default-constructor-should-27965

5.19 LAB: Nutritional information (classes/constructors) Given main(), complete the FoodItem class (in file FoodItem.java) with constructors to initialize each food item. The default constructor should initialize the name to "None" and all other fields to 0.0. The second constructor should have four parameters (food name, grams of fat, grams of carbohydrates, and grams of protein) and should assign each private field with the appropriate parameter value. Ex: If the input is: M&M's 10.0 34.0 2.0 1.0 where M&M's is the food name, 10.0 is the grams of fat, 34.0 is the grams of carbohydrates, 2.0 is the grams of protein, and 1.0 is the number of servings, the output is: Nutritional information per serving of None: Fat: 0.00 g Carbohydrates: 0.00 g Protein: 0.00 g Number of calories for 1.00 serving(s): 0.00 Nutritional information per serving of M&M's: Fat: 10.00 g Carbohydrates: 34.00 g Protein: 2.00 g Number of calories for 1.00 serving(s): 234.00 The first FoodItem above is initialized using the default constructor. public class FoodItem { private String name; private double fat; private double carbs; private double protein; // TODO: Define default constructor // TODO: Define second constructor with parameters to initialize private fields (name, fat, carbs, protein) public String getName() { return name; } public double getFat() { return fat; } }

Akash M.

write-a-full-class-definition-for-a-class-named-gastank-and-containing-the-following-members-a-data-member-named-amount-of-type-double-a-constructor-that-no-parameters-the-constructor-initia-49829

Text: Write a full class definition for a class named GasTank, and containing the following members: A data member named amount of type double. A constructor that takes no parameters. The constructor initializes the data member amount to 0. A function named addGas that accepts a parameter of type double. The value of the amount instance variable is increased by the value of the parameter. A function named useGas that accepts a parameter of type double. The value of the amount data member is decreased by the value of the parameter. However, if the value of amount is decreased below 0, amount is set to 0. A function named isEmpty that accepts no parameters and returns a boolean value. isEmpty returns a boolean value: true if the value of amount is less than 0.1, and false otherwise. A function named getGasLevel that accepts no parameters. getGasLevel returns the value of the amount data member. class GasTank { private: double amount; public: GasTank(); void addGas(double); void useGas(double); bool isEmpty(); double getGasLevel(); }; GasTank::GasTank() { amount = 0; } void GasTank::addGas(double a) { amount += a; } void GasTank::useGas(double a) { amount -= a; if (amount < 0) amount = 0; } bool GasTank::isEmpty() { if (amount < 0.1) return true; else return false; } double GasTank::getGasLevel() { return amount; }

Supreeta N.

answers-in-c-please-710-points-given-person-classextend-it-and-define-doctor-class-here-are-the-signatures-of-the-constructors-and-methods-provided-by-person-class-1-each-person-has-a-nameas-32564

7. (10 points) Given Person class, extend it and define Doctor class. Here are the signatures of the constructors and methods provided by Person class. (1) Each person has a name (as a string) and age (as an int). (2) Constructor Person() define name as "anonymous" and age as 18. (3) Constructor Person(string name) uses given parameter name to initialized data member name, and initialize age as 18. (4) Constructor Person(string name, int age) uses given parameter name to initialize data member age. If given parameter age is in the range of [0, 130], then uses given parameter age to initialize data member age, otherwise, set data member age to be 18. (5) Method string getName() returns the name of a person. (6) Method int getAge() returns the age of a person. (7) Method void setAge(int age) uses given parameter age to reset data member age if the former is in the range of [0, 130], otherwise, leave the corresponding data member as it is. (8) Method void setName(string name) uses given parameter name to reset data member name. Each doctor is a person, just with additional data member to describe the name of all insurances he/she takes. This data member insurances can be a vector of string. Your job: Declare Doctor class as a subclass of Person and define the following methods. NO NEED TO define Person class. (1) Default constructor Doctor() with insurances initialized by "medicaid" and "medicare". (2) Write a method, given a string representing a specific insurance, search whether it is in the vector of insurances or not, if yes, return true, otherwise, return false.

Akash M.


*

Recommended Textbooks

-
Computer Science and Information Technology

Computer Science and Information Technology

Trishna Knowledge Systems 2018 Edition
achievement 1,682 solutions
Introduction to Programming Using Python

Introduction to Programming Using Python

Y. Daniel Liang 1st Edition
achievement 1,588 solutions
Computer Science - An Overview

Computer Science - An Overview

Glenn Brookshear, Dennis Brylow 12th Edition
achievement 1,872 solutions

*

Transcript

-
00:01 Hello students so let us look at the removing consecutive duplicate letter would be consecutive duplicate letters would be since we have not used the we can also use here using namespace std using namespace std so then for loop here char ch would be equal to name and then if compacted…
Need help? Use Ace
Ace is your personal tutor. It breaks down any question with clear steps so you can learn.
Start Using Ace
Ace is your personal tutor for learning
Step-by-step explanations
Instant summaries
Summarize YouTube videos
Understand textbook images or PDFs
Study tools like quizzes and flashcards
Listen to your notes as a podcast
Continue solving this problem
Create a free account to:
  • View full step-by-step solution
  • Ask follow-up questions with Ace AI
  • Save progress and study later
Continue Free
Numerade

Get step-by-step video solution
from top educators

Continue with Clever
or



By creating an account, you agree to the Terms of Service and Privacy Policy
Already have an account? Log In

A free answer
just for you

Watch the video solution with this free unlock.

Numerade

Log in to watch this video
...and 100,000,000 more!


EMAIL

PASSWORD

OR
Continue with Clever