In this code I am basically building a program for a health club. The user inputs the desired membership and months and then it prints the total fees. The program runs perfectly for option 2&4 however for 1 it gives two outputs and for 3 none at all. I guess there is a slight bug in my code which I really cant find. The program is fine for 2 but tit calculates two values for 1 and it displays none for 3.
#include <iostream>
using namespace std;
void menu ()
{
cout << "\n\t\tHealth Club Membership Menu\n\n";
cout << "1. Standard Adult Membership\n";
cout << "2. Child Membership\n";
cout << "3. Senior Citizen Membership\n";
cout << "4. Quit the Program\n\n";
cout << "Enter your choice: ";
}
void fees(int member,int months)
{
cout<<"The fees is Rs.";
cout<<(member*months);
}
int main()
{
int months, choice;
int adult=40;
int child=20;
int senior=50;
do{menu();
{
cin>>choice;
if (choice>=4)
{
cout<<"You have quit your membership\n";
return 0;
}
cout<<"Please enter the number of months you want"<<endl;
cin>>months;
switch (choice)
{
case 0:
choice==1;
fees(adult,months);
}
case 1:
{
choice==2;
fees(child,months);
}
case 2:
{
choice==3;
fees(senior,months);
}
}
}
}
while((choice>=1) || (choice<4));
return 0;
}
choice==1;does nothing.