#include <iostream>
#include <iomanip>
usingnamespace std;
int main ()
{
constfloat
LASER_TAG=18.75,
BOWLING=6.5,
ICE_SKATING=8.25,
ROCK_CLIMBING=16.5;
float activityCost;
int groupSize,activitySelect;
float totalCost;
cout<<"How many people are in your group today? ";
cin>>groupSize;
while(groupSize<1)
{
cout<<"How many people are in your group today? ";
cin>>groupSize;
}
cout<<"What activity would you like to do today? "<<endl
<<"1. Laser tag"<<endl
<<"2. Bowling"<<endl
<<"3. Ice Skating"<<endl
<<"4. Rock Climbing"<<endl
<<"Please enter activity number followed by return key: ";
cin>>activitySelect;
while(activitySelect<1||activitySelect>4)
{
cout<<"What activity would you like to do today? "<<endl
<<"1. Laser tag"<<endl
<<"2. Bowling"<<endl
<<"3. Ice Skating"<<endl
<<"4. Rock Climbing"<<endl
<<"Please enter activity number followed by return key: ";
cin>>activitySelect;
}
switch (activitySelect)
{
case'1':
activityCost=LASER_TAG;
break;
case'2':
activityCost=BOWLING;
break;
case'3':
activityCost=ICE_SKATING;
break;
case'4':
activityCost=ROCK_CLIMBING;
break;
default:cout<<"Try Again"<<endl;
break;
}
totalCost=activityCost*groupSize;
cout<<setprecision(2)<<fixed
<<"The total cost today for "<<groupSize<<" people is: "<<endl
<<totalCost<<endl
<<"Thank you and have a nice day!"<<endl;
return 0;
}
returns error "activity cost is bieng used without being initialized
Your case labels are incorrect. You're using character literals, not integer values. activitySelect is an int, therefore, your labels should also be int values.
case 1:
You're getting the error because you're taking the default branch and then falling through to the calculation on line 65 without setting actvity cost.