This program is about computing what the buyer supposed to pay. (Funeral System)

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:

#include <iostream>
#include<windows.h>
#include<conio.h>

using namespace std;

int main(int argc, char** argv)

{
system("color 7E");
int funeral= 800;
int embalm= 500;
double flower= 350;
double formalin=500;
double regularCoffin= 14000;
double mediumCoffin=270000;
double glassedCoffin= 120000;
double specialCoffin=180000;
double totalAmount= 200000;
char coffin;
char y, n;
char sagot;
char answer;


{

cout<<"What package do you want?.";
cout<<"\n" << endl;
cout<<"[A] Package A--------> Funeral" << endl;
cout<<"[B] Package B--------> Funeral and Embalm" << endl;
cout<< "and Porcelain lettering on grave" << endl;
cout<<"[C] Package C--------> Complete Package: (includes food, games:cards, etc.)" << endl;
cin>>answer;
system("cls");


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;


if(sagot=='y')

cout<<glassedCoffin+funeral+embalm+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+embalm+flower+formalin;

if(sagot=='n')
cout<<"Final total amount.";


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;

if(sagot=='y')

cout<<totalAmount+flower+formalin;

if(sagot=='n')
cout<<"Final total amount.";




}

}
system("pause>0");
return 0;
}
You're a genius!!!
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.";
}
}
else if(coffin=='b')
{
...
}
Topic archived. No new replies allowed.