Hi guys, i'm doing this funeral system and the first choice of the 2nd question is ok (a) but the 2nd 3rd and 4th choice doesn't make sense T____T when i input letter b you still have to enter a key 2 times so that the next question appears, and the 3rd choice makes 3 times so that the next question too does appear, here's my code:
switch (answer)
{
case 'a':
case 'A':
cout << "Enter the type of coffin you want to order: (Please answer an amount, accordingly).";
cout<<"\n";
cout<<"(Coffin's amount) ";
cout<<"\n";
cout<< "\n[A] Regular coffin= Php.14000";
cout<<" \n[B] Medium coffin=Php.270000";
cout<<" \n[C] Glassed coffin= Php.120000";
cout<<" \n[D] Special coffin= 180000";
cout<<"\n";
cin>> coffin;
if(coffin=='a')
cout<<"Do you still want to buy the flowers and formalin?.(y/n)";
cout <<"\n";
cout<<"\n";
cin>>sagot;
if(sagot=='y')
cout<<regularCoffin+funeral+flower+formalin;
if(sagot=='n')
cout<< "Final total amount.";
if(coffin=='b')
cout<<"Do you still want to buy the flowers and formalin?.(y/n)";
cout <<"\n";
cout<<"\n";
cin>>sagot;
if(sagot=='y')
cout<<mediumCoffin+funeral+flower+formalin;
if(sagot=='n')
cout<<"Final total amount.";
if(coffin=='c')
cout<<"Do you still want to buy the flowers and formalin?.(y/n)";
cout <<"\n";
cout<<"\n";
cin>>sagot;
if(sagot=='y')
cout<<glassedCoffin+funeral+flower+formalin;
if(sagot=='n')
cout<<"Final total amount.";
if(coffin=='d')
cout<<"Do you still want to buy the flowers and formalin?.(y/n)";
cout <<"\n";
cout<<"\n";
cin>>sagot;
if(sagot=='y')
cout<<specialCoffin+funeral+flower+formalin;
if(sagot=='n')
cout<<"Final total amount.";
case 'b':
case 'B':
cout << "Enter the type of coffin you want to order: (Please answer an amount, accordingly).";
cout<<"\n";
cout<<"(Coffin's amount) ";
cout<<"\n";
cout<< "\n[A] Regular coffin= Php.14000";
cout<<" \n[B] Medium coffin=Php.270000";
cout<<" \n[C] Glassed coffin= Php.120000";
cout<<" \n[D] Special coffin= 180000";
cout<<"\n";
cin>> coffin;
if(coffin=='a')
cout<<"Do you still want to buy the flowers and formalin?.(y/n)";
cout <<"\n";
cout<<"\n";
cin>>sagot;
if(sagot=='y')
cout<<regularCoffin+funeral+embalm+flower+formalin;
if(sagot=='n')
cout<< "Final total amount.";
if(coffin=='b')
cout<<"Do you still want to buy the flowers and formalin?.(y/n)";
cout <<"\n";
cout<<"\n";
cin>>sagot;
if(sagot=='y')
cout<<mediumCoffin+funeral+embalm+flower+formalin;
if(sagot=='n')
cout<<"Final total amount.";
if(coffin=='c')
cout<<"Do you still want to buy the flowers and formalin?.(y/n)";
cout <<"\n";
cout<<"\n";
cin>>sagot;
case 'c':
case 'C':
cout << "Enter the type of coffin you want to order: (Please answer an amount, accordingly).";
cout<<"\n";
cout<<"(Coffin's amount) ";
cout<<"\n";
cout<< "\n[A] Regular coffin= Php.14000";
cout<<" \n[B] Medium coffin=Php.270000";
cout<<" \n[C] Glassed coffin= Php.120000";
cout<<" \n[D] Special coffin= 180000";
cout<<"\n";
cin>> coffin;
if(coffin=='a')
cout<<"Do you still want to buy the flowers and formalin?.(y/n)";
cout <<"\n";
cout<<"\n";
cin>>sagot;
if(sagot=='y')
cout<<totalAmount+flower+formalin;
if(sagot=='n')
cout<< "Final total amount.";
if(coffin=='b')
cout<<"Do you still want to buy the flowers and formalin?.(y/n)";
cout <<"\n";
cout<<"\n";
cin>>sagot;
if(sagot=='y')
cout<<totalAmount+flower+formalin;
if(sagot=='n')
cout<<"Final total amount.";
if(coffin=='c')
cout<<"Do you still want to buy the flowers and formalin?.(y/n)";
cout <<"\n";
cout<<"\n";
cin>>sagot;
if(sagot=='y')
cout<<totalAmount+flower+formalin;
if(sagot=='n')
cout<<"Final total amount.";
if(coffin=='d')
cout<<"Do you still want to buy the flowers and formalin?.(y/n)";
cout <<"\n";
cout<<"\n";
cin>>sagot;
An if clause requires for more than one statement { } in order to determine when it ends. I'd guess that you mean something like that:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
if(coffin=='a')
{
cout<<"Do you still want to buy the flowers and formalin?.(y/n)";
cout <<"\n";
cout<<"\n";
cin>>sagot;
if(sagot=='y')
{
cout<<totalAmount+flower+formalin;
if(sagot=='n')
cout<< "Final total amount.";
}
}
elseif(coffin=='b')
{
...
}