Que- Make a program by using switch case?
#include<iostream>
using namespace std;
int main()
{
int button,cont;
cont=1;
cout<<"1.on"<<endl<<"2.off"<<endl;
cout<<"water filling switch :- ";
cin>>button;
switch (button)
{
case 1: cout<<"water filling start"<<endl;
cout<<"water is now filled at low level"<<endl;
cont=1;
break;
case 2: cout<<"water is not filling";
cont=0;
break;
};
if(cont==1)
{
cout<<"3.close tap"<<endl<<"4.filling continue"<<endl;
cout<<"water filling switch :- ";
cin>>button;
switch(button)
{
case 3: cout<<"close tap"<<endl;
cout<<"filling stop";
cont=0;
break ;
case 4: cout<<"water filling is continue..."<<endl;
cout<<"water is now filled at medium level"<<endl;
break;
};
if(cont==1)
{
cout<<"5.close tap"<<endl<<"6.filling continue"<<endl;
cout<<"water filling switch :- ";
cin>>button;
switch(button)
{
case 5: cout<<"close tap"<<endl;
cout<<"filling stop";
break ;
case 6: cout<<"water filling is continue..."<<endl;
cout<<"water is now filled at high level"<<endl;
cout<<"cooler is fully filled water filling stops";
break;
};
}
}
return 0;
}
Result:-