void circle::get_C()
{
cin>>radius;
}
void circle::print_C()
{
cout<<radius;
}
float circle::area()
{
return 3.14*radius*radius;
}
void kitchen::get_K()
{
cin>>num1;
int i;
for(i=0;i<num1;i++)
{
cin>>ing_Cost[i].name;
cin>>ing_Cost[i].price;
}
}
void kitchen::print_K()
{
cout<<num1;
int i;
for(i=0;i<num1;i++)
{
cout<<ing_Cost[i].name;
cout<<ing_Cost[i].price;
}
}
float kitchen::get_Cost(char a[])
{
int i;
for(i=0;i<num1;i++)
{
if(strcmp(ing_Cost[i].name,a)==0)
return ing_Cost[i].price;
}
}
void cookeditem::get_CI()
{
cin>>num;
int i;
for(i=0;i<num;i++)
{
cin>>ing_Qty[i].name;
cin>>ing_Qty[i].qty;
}
}
void cookeditem::print_CI()
{
cout<<num;
int i;
for(i=0;i<num;i++)
{
cout<<ing_Qty[i].name;
cout<<ing_Qty[i].qty;
}
}
class pizza:public circle,public cookeditem
{
protected:
float cost;
public:
void get_P()
{
circle::get_C();
cookeditem::get_CI();
}
void compute_Cost(kitchen k)
{
int i;
for(i=0;i<num;i++)
{
cost+=(ing_Qty[i].qty/100)*k.get_Cost(ing_Qty[i].name);
}
cost=cost*circle::area();
}
void print_P()
{
cout<<fixed<<setprecision(2)<<cost;
}
pizza()
{
cost=0.0;
}
};
class veg_Pizza:public pizza
{
public:
void get_P()
{
pizza::get_P();
}
void compute_Cost(kitchen k)
{
pizza::compute_Cost(k);
cost+=50;
}
void print_P()
{
pizza::print_P();
}
veg_Pizza()
{
pizza();
}
};
class chik_Pizza:public pizza
{
public:
void get_P()
{
pizza::get_P();
}
void compute_Cost(kitchen k)
{
pizza::compute_Cost(k);
cost+=100;
}
void print_P()
{
pizza::print_P();
}
chik_Pizza()
{
pizza();
}
};
{
cin>>radius;
}
void circle::print_C()
{
cout<<radius;
}
float circle::area()
{
return 3.14*radius*radius;
}
void kitchen::get_K()
{
cin>>num1;
int i;
for(i=0;i<num1;i++)
{
cin>>ing_Cost[i].name;
cin>>ing_Cost[i].price;
}
}
void kitchen::print_K()
{
cout<<num1;
int i;
for(i=0;i<num1;i++)
{
cout<<ing_Cost[i].name;
cout<<ing_Cost[i].price;
}
}
float kitchen::get_Cost(char a[])
{
int i;
for(i=0;i<num1;i++)
{
if(strcmp(ing_Cost[i].name,a)==0)
return ing_Cost[i].price;
}
}
void cookeditem::get_CI()
{
cin>>num;
int i;
for(i=0;i<num;i++)
{
cin>>ing_Qty[i].name;
cin>>ing_Qty[i].qty;
}
}
void cookeditem::print_CI()
{
cout<<num;
int i;
for(i=0;i<num;i++)
{
cout<<ing_Qty[i].name;
cout<<ing_Qty[i].qty;
}
}
class pizza:public circle,public cookeditem
{
protected:
float cost;
public:
void get_P()
{
circle::get_C();
cookeditem::get_CI();
}
void compute_Cost(kitchen k)
{
int i;
for(i=0;i<num;i++)
{
cost+=(ing_Qty[i].qty/100)*k.get_Cost(ing_Qty[i].name);
}
cost=cost*circle::area();
}
void print_P()
{
cout<<fixed<<setprecision(2)<<cost;
}
pizza()
{
cost=0.0;
}
};
class veg_Pizza:public pizza
{
public:
void get_P()
{
pizza::get_P();
}
void compute_Cost(kitchen k)
{
pizza::compute_Cost(k);
cost+=50;
}
void print_P()
{
pizza::print_P();
}
veg_Pizza()
{
pizza();
}
};
class chik_Pizza:public pizza
{
public:
void get_P()
{
pizza::get_P();
}
void compute_Cost(kitchen k)
{
pizza::compute_Cost(k);
cost+=100;
}
void print_P()
{
pizza::print_P();
}
chik_Pizza()
{
pizza();
}
};
The error that is showing in the problem "cost of pizza"is Segmentation fault (core dumped)
ReplyDeletePlease make sure you have copied correctly.
ReplyDeleteIf error persists,kindly email me the screenshot of the input,expected output and output.
I will look into it at once.
Sir, code is not present on the blog now, instead its showing advertisement.Please rectify.
ReplyDeleteThere were some issues.
DeleteThey have been taken care of.
It should be visible now.
Thank you sir. You are doing great job in helping us, especially mechanical :)
Deleteformat the answer to 2 decimal places
ReplyDeleteNoted.Thanks!
DeleteCorrected.Please try again.
ReplyDeleteits woking ok!!!!! you posted even the previous code...
ReplyDelete