-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPRA_28
123 lines (118 loc) · 2.19 KB
/
PRA_28
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
/* A program to demonstrate hybrid inheritance */
#include<iostream>
using namespace std;
class Company
{
public:
Company()
{
cout << " COMPUTER PVT. LTD. ";
}
};
class Product:public Company
{
protected:
int n,q,p;
public:
Product()
{
pro();
choice();
}
void pro()
{
cout<<endl<<"1. Laptop : 45000";
cout<<endl<<"2. Tablet : 20000";
cout<<endl<<"3. Mobile : 10000";
cout<<endl<<"4. Headspree : 200";
cout<<endl<<"5. Mouse : 150";
cout<<endl<<"6. Keyboard : 250";
cout<<endl<<"7. Processor : 22000";
cout<<endl;
}
float choice()
{
cout << endl<< "PURCHASE ANY ONE PRODUCT "<<endl;
cout << "Enter Your Choice : ";
cin >> n;
cout << "Enter Quantity : ";
cin >> q;
cout<< endl;
switch(n)
{
case 1:
cout <<endl<<q<< " LAPTOP OF PRISE ";
p=45000;
break;
case 2:
cout <<endl<<q<< " TABLET OF PRISE ";
p=20000;
break;
// cout <<endl<<
case 3:
cout <<endl<<q<< " MOBILE OF PRISE ";
p=10000;
break;
case 4:
cout <<endl<<q<< " HEADSPREE OF PRISE ";
p=200;
break;
case 5:
cout <<endl<<q<< " MOUSE OF PRISE ";
p=150;
break;
case 6:
cout <<endl<<q<< " KEYBOARD OF PRISE ";
p=250;
break;
case 7:
cout <<endl<<q<< " PROCESSOR OF PRISE ";
p=22000;
break;
default:
cout <<" Enter Valid Choice ";
}
}
};
class Payment
{
public:
Payment(int &r,int &i)
{
cout << r<<" HAS BEEN PURCHASED."<<endl;
cout<<"Pay "<< r*i <<" INR";
}
};
class Coustomer:public Product,public Payment
{
public:
Coustomer():Payment(p,q),Product()//constructor in multiple iinheritance
{
cout << endl<<endl<<"THANK YOU ...";
}
};
int main()
{
Coustomer c;
return 0;
}
/*
Output:
COMPUTER PVT. LTD.
1. Laptop : 45000
2. Tablet : 20000
3. Mobile : 10000
4. Headspree : 200
5. Mouse : 150
6. Keyboard : 250
7. Processor : 22000
PURCHASE ANY ONE PRODUCT
Enter Your Choice : 5
Enter Quantity : 3
3 MOUSE OF PRISE 150 HAS BEEN PURCHASED.
Pay 450 INR
THANK YOU ...
--------------------------------
Process exited after 11.53 seconds with return value 0
Press any key to continue . . .
*/