MENU
Question -

Define a class Stock in C++ with following description;
Private Memebrs
•  ICode of type integer (Item Code)
•  Item of type string (Item Name)
•  Price of type float (Price of each item)
•  Qty of type integer (Quantity in stock)
•  Discount of type float (Discount percentage on the item)
•  A member function FindDisc() to calculate discount as per the following rule :
If Qty< =50              Discount is 0



Answer -

class Stock
 {
 int ICode, Qty ; 
char Item[20]    ;
 float Price, Discount; 
void FindDisc ()    ;
 public :
 void Buy ()    ;
 void ShowAll ()    ;
 };
 void Stock :    : Buy ( )
{
cin>>ICode ; 
gets (Item) ; 
cin >> Price ; 
cin >> Qty ;
 Find Disc () ;
 }
 void Stock : : FindDisc ()
 {
 If (Qty < = 50)
 Discount = 0 ; 
else if (Qty < = 100)
 Discount =5;    // = 0.05 ;
 else
 Discount = 10 ;    // =0.1;
}
 void Stock :    : ShowAll ()
 {
c o u t < < I C o d e < < ' \ t ' < < l t e m < < 1 \ 
t1<
t1<
 }

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
×