Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Must be done in C++. Can use loops, strings, arrays, functions, static fields, a

ID: 668924 • Letter: M

Question

Must be done in C++. Can use loops, strings, arrays, functions, static fields, and constructors/destructors.

Create a class named IceCreamCone with fields for flavor, number of scoops, type of
cone, and price. Unless arguments are supplied, flavor defaults to “Vanilla”, number of
scoops defaults to 1, and cone type defaults to “Sugar”. The constructor calculates the
price based on 75 cents per scoop, with an additional 40 cents for a waffle cone. Write
a main()function demonstrating that the class works correctly.

Explanation / Answer

#include #include using namespace std; int numberCones; int numberScoops; float price; class IceCreamCone{ vector flavors; public: IceCreamCone(); void getFlavorsForCone(int); void printCone(); float calcPrice(int); }; IceCreamCone::IceCreamCone(){ flavors.resize(5); } void IceCreamCone::getFlavorsForCone(int numberScoopsForCone){ flavors.resize(numberScoopsForCone); for(int i = 0;i