#include <iostream>
#include <iomanip>
using namespace std;
enum sizes{small, medium, large, jumbo};
sizes options(int drinkSize, int popcornSize);
void printTotal(sizes price);
int main()
{
int popcornSize, drinkSize;
cout<<"Please pick the size of your popcorn: "<<endl;
cout<<"1. Small"<<endl;cout<<"2. Medium"<<endl;cout<<"3. Large"<<endl;cout<<"4. Jumbo"<<endl;
cin>>popcornSize;
cout<<"Please pick the size of your Soda: "<<endl;
cout<<"1. Small"<<endl;cout<<"2. Medium"<<endl;cout<<"3. Large"<<endl;cout<<"4. Jumbo"<<endl;
cin>>drinkSize;
printTotal(options(drinkSize, popcornSize));
return 0;
}
sizes options(int drinkSize, int popcornSize)
{
if (drinkSize==1 || popcornSize==1)
{
return medium;
}
else if (drinkSize==2 || popcornSize==2)
{
return small;
}
else if (drinkSize==3 || popcornSize==3)
{
return large;
}
else
return jumbo;
}
void printTotal(sizes price)
{
int drinkSize, popcornSize;
double drinkPrice = 0.0, popcornPrice = 0.0;
switch (drinkSize)
{
case small:
drinkPrice=1.50;
break;
case medium:
drinkPrice=2.50;
break;
case large:
drinkPrice=3.75;
break;
case jumbo:
drinkPrice=4.50;
break;
}
switch (popcornSize)
{
case small:
popcornPrice=1.25;
break;
case medium:
popcornPrice=2.25;
break;
case large:
popcornPrice=3.50;
break;
case jumbo:
popcornPrice=4.25;
break;
}
cout<<"Total is:$"<<drinkPrice+popcornPrice<<setprecision(2)<<endl;
}
This program is suppose to ask the user for the size of the popcorn and the drink and then output the total of their choices using the enumeration type and swtich cases for the size prices. I dont know what I am doing wrong. I keep getting 2.75 as my total no matter which size of popcorn and soda I pick. Any help will be much appreciated! I am a beginner and this is my first computer science course.