MENU
Question -

Define a class Customer with the following specifications.   
Private Members:
Customer_no integer
Customerjname char (20)
Qty integer
Price, TotalPrice, Discount, Netprice float
Member Functions:
Public members:

1. A constructer to assign initial values of Customer_no as 111, Customer_name as “Leena”, Quantity as 0 and Price, Discount and Netprice as 0.
2. Input() – to read data members (Customer_ no, Customer_name, Quantity and Price) call Caldiscount().
3. Caldiscount ( ) – To calculate Discount according to TotalPrice and NetPrice
TotalPrice = Price*Qty
TotalPrice > =50000 – Discount 25% of TotalPrice TotalPrice >=25000 and TotalPrice <50000 – Discount 15% of TotalPrice TotalPrice <25000 – Discount 10% of TotalPrice Netprice = TotalPrice-Discount Show() – to display Customer details.



Answer -

class Customer
 {
 int Customer_no; 
char Customer_name; 
int Qty;
 float Price, TotalPrice, Discount, Netprice; 
public:
 Customer ( )    [1]
 {
 Customer_no = 111;
 strcpy( Customer_name, "Leena");
 Qty=0 ;
 Price =0, Discount=0, Netprice=0;
 }
 void Input ()    [1]
{
 cin>>Custome r_no; 
gets( Customer_name); 
cin>>Qty>>TotalPrice;
 Caldiscount();
 }
 void Caldiscount()    [1]
 {
 TotalPrice = Price*Qty; 
if ( TotalPrice >= 50000)
 Discount = 0.25 * TotalPrice;
 else if (TotalPrice >= 2 5000) 
Discount = 0.15 * TotalPrice; 
else
 Discount = 0.10 * TotalPrice; 
Netprice = TotalPrice - Discount;
 }
 void Show ( )    [1]
 {
 cout<
 }
 };

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
×