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
×