Question: Use c++ Write a class called Snack. It should have data members for the name of a snack, the price of the snack (double), and

Use c++

Write a class called Snack. It should have data members for the name of a snack, the price of the snack (double), and the number of calories in the snack (int). The class should have a constructor that takes three parameters and uses them to initialize the data members. It should also have a default constructor that initializes the data members to "bottled water", 1.75 and 0, respectively. The class should have get methods for all three data members.

The functions should have the following names:

For the Snack class:

getName

getPrice

getNumCalories

For example, these classes could be used as follows:

 Snack s1("corn chips", 0.75, 200); Snack s2("candy bar", 1.25, 300); Snack s3("root beer", 2.00, 450); 

The files must be named Snack.hpp, Snack.cpp, SnackMain.cpp

Please explain and use comments

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!