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;iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.