-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpizza.cpp
More file actions
164 lines (118 loc) · 2.81 KB
/
Copy pathpizza.cpp
File metadata and controls
164 lines (118 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/* Pizza is a delicious circular food item that is a favorite for many people. Given the radius of the pizza, ingredients required for the preparation of the pizza, per square cm (cm2) area of the pizza and cost of its ingredients per 100 grams, design an OOP model and write a C++ program to calculate the cost of the pizza. Add Rs 50 for veg pizza and Rs 100 for chicken pizza. Use 3.14 for pi. Your program should get all the ingredients available in the kitchen with their cost per 100 grams, as an input. Assume that all the ingredients required for the preparation of the pizza is available in the kitchen.
Note: Syntax to print 'x' decimal places of variable 'a'
include <iomanip>
use
cout<<fixed<<setprecision(x)<<a;
Input Format
Give 0 for veg pizza and 1 for chicken pizza
Radius of pizza
Number of ingredients required for the preparation of the pizza
Name of ingredient1
Quantity of ingredient1 required (in grams)
Name of ingredient2
Quantity of ingredient2 required
....
Name of ingredient-n
Quantity of ingredient-n required
Number of ingredients available in the kitchen.
Name of ingredient-1 available in the kitchen
Cost of 100 gm of ingredient1 available in kitchen
Name of ingredient-2 in kitchen
Cost of 100 gm of ingredient2 in kitchen
....
Name of ingredient-n in kitchen
Cost of 100 gm of ingredient-n in kitchen
Output Format
Cost of pizza
*/
#include<iostream>
using namespace std;
#include<string.h>
#include<iomanip>
class circle
{
protected:
float radius;
public:
void get_C();
void print_C();
float area();
};
struct ingre_Cost
{
char name[30];
float price;
};
class kitchen
{
protected:
int num1;
//ingredients in the kitchen and their cost
ingre_Cost ing_Cost[20];
public:
void get_K();
void print_K();
//Given name of ingredients
//return cost of 100gm of it
float get_Cost(char*);
};
struct ingre_Qty
{
char name[30];
float qty;
};
class cookeditem
{
protected:
//number of ingredients
int num;
// names of ingredients and their quantity in
// Pizza
ingre_Qty ing_Qty[20];
public:
void get_CI();
void print_CI();
};
//Create a class pizza that inherits circle and cookeditem
//Create another class veg_Pizza inherited that inherits pizza
//Create another class chik_Pizza inherited that inherits pizza
class pizza:public circle,public cookeditem
{
};
class veg_Pizza:public pizza
{
};
class chik_pizza:public pizza
{
};
int main()
{
int ch;
cin>>ch;
if (ch==0)
{
//Create an oject for veg pizza
veg_Pizza p;
//get radius of circle(pizza)
// get ingredients and quantity required for 1 square centimeter
p.get_P();
//get items in kitchen and their cost
kitchen k;
k.get_K();
//compute cost
p.compute_Cost(k);
p.print_P();
}
else
{
if (ch==1)
{
chik_Pizza c;
c.get_P();
kitchen k1;
k1.get_K();
c.compute_Cost(k1);
c.print_P();
}
}
}