Hi every body I hope you are having a great day, I am new to c++ programming and I while I was practicing c++ questions, I got stucked in the program, after spending 4 hours straight I got completely exhausted. Can some help me with the program of code?? thanks:
Program:
Write a C++ program for a new ice cream vendor called PopSalon. The management of PopSalon has decided that they are going to sell their popcorn in 11 different flavors namely: chocolate, English toffee, salted caramel, caramel, jalapeno, cheese, spiced cheese, plain sated, buttered, salt and pepper, and garlic. Carefully design the program by observing the following rules.
PopSalonis charging $100 for small pack, $250 for medium sized pack $500 for large sized pack and $750 large size tin pack. Hence you will need a function to determine the size of the packand based on that the price. If a user enters option number other than the ones displayed, your program should display an invalid input message and ask the user to re-enter the option number.
Pop Salon allows its customers to purchase a gift wrapper with their popcorn. If the customer wants to purchase the wrapper he will have to pay an additional $50. This amount should be added to the total amount payable by the user.
If the customer asks for chocolate sauce, caramel sauce, or melted cheese as an additional topping then he will have to pay an additional amount of $50, $30 and, $60 respectively. Design a function that will be called if the customer chooses an additional topping.
The program should show a menu that asks the customer for his requirements and then displays the final payable amount with full details about the flavor, the size of the pack and details regarding any additional toppings.
For service quality inspection and monthly product promotions, the program should ask the user to enter his/her contact details including name, mobile number and email address, and select between the options good, neutral and bad against the quality of the service provided.
In the end create a class destructor that displays a thank you message to the user. Design your program using sound OOP practices. Carefully determine the data members, member functions, access specifiers, activities to be performed in the constructor. Make sure that you use good naming conventions in your code.
#include<iostream>
#include<string>
using namespace std;
class PopSalon{
private:
string chocolate,English toffee,salted caramel,caramel,jalapeno,cheese,spiced cheese,plain sated,buttered,salted pepper,garlic;
int tamount;
public:
void setsmallpack(){
cout<<"You have selected small pack:"<<endl;
cout<<"Small pack price is $100"<<endl;
return tamount+100;
}
void setmediumpack(){
cout<<"You have selected medium pack:"<<endl;
cout<<"Medium pack price is $250"<<endl;
return tamount+250;
}
void setlargepack(){
cout<<"You have selected large pack:"<<endl;
cout<<"Large pack price is $500"<<endl;
return tamount+500;
}
void setlargetinpack(){
cout<<"You have selected large tin pack:"<<endl;
cout<<"Large Tin pack price is $750"<<endl;
return tamount+750;
}
new ice cream vendor called PopSalon. they are going to sell their popcorn
^^^ I haz found the problem :P
Kidding aside, before trying to code, think about what you need to DO, by reading the WHOLE assignment and drawing or visualizing how it will work (this is your 'design' phase).
For example, you need to know:
- which size the user picked.
-- to get that, you need to talk to the user and get a response. this is #1.
- you need to know if the user wants gift wrap. this feels like a boolean variable: they do or they do not. You need to talk to the user to know if they want it....
- you need to know if the user wants a topping. If they do, you need to get the details on that.
I am leaving off the rest of the requirements for now, as the above are the core of what you need to focus on. However, READ BETWEEN THE LINES as you look at the requirements. For example "If the customer asks for chocolate sauce, caramel sauce, or melted cheese as" tells me something. It tells me the user needs to interact, be offered a choice of these things and that you need to get that choice and handle it somehow. Its stated indirectly, but you need to do it anyway.... this is a good example of how real life requirements can come down to you; often the user says in passing something they want that you need to capture so it gets done.
you should not have a function to select each pack/size. This is hard to explain why, but it is far better to have one function that lets them pick the pack/size. What do you know so far in c++, do you know vector/array? Enum? I am going to assume you do, because classes should be after those things, but you may not, and if so, this won't help you but...
what if you had an array like this:
enum packages
{
small, medium, large, tin, maxpax
};
const int prices[maxpax] = {100,250,500,750};
...
tamount += prices[medium]; //like this...
and you can do strings as well:
string packwords[maxpax] = {"Small: ", "Medium: ", "Large: ", "Large with tin: "};
cout << "you have selected " << packwords[choice] << "price of " <<prices[choice] << endl;
or whatever words you need to use, you get the idea?
these things are in your class, along with the booleans I mentioned, eg something along the lines of
enum packages //this is outside the class as I believe you want to use it in main with your menu etc too.
{
small, medium, large, tin, maxpax
};
class PopSalon
{
private:
bool has_topping;
bool has_giftwrap;
const int prices[maxpax] = {100,250,500,750};
string packwords[maxpax] = {"Small: ", "Medium: ", "Large: ", "Large with tin: "};
... etc
public:
...
};
-- you MAY need an array of strings with the topping names or flavors etc, but you don't need one string for each. An enum may also be useful there. See what you think works best.