Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
9.3k views
in Computer by (64.2k points)

Define a class Outfit in C++ with the following description: Private Members:

OCode of type string
OType of type string
OSize of type integer
OFabric of type string
OPrice of type float

A function IitPrice() which calculates and assigns the value of OPrice as follows: For the value of OFabric "DENIM",

OType         OPrice (Rs)

TROUSER    1500

JACKET       2500

For OFabric other than "DENIM" the above mentioned OPrice gets reduced by 25%

Public Members:

A constructor to assign initial values of OCode, OType and OFabric with the word "NOT INITIALISED" and OSize and OPrice with 0.

A function Input() to input the values of the data members OCode, OType, OSize ad OFabric and invoke the InitPrice() function.

A function Display() which displays the content of all the data members for an Outfit.

1 Answer

+1 vote
by (69.4k points)
selected by
 
Best answer

class Outfit

{

char OCode[15];

char OType[15];

int OSize;

char OFabric[15];

float OPrice;

void InitPrice()

{

if(strcmp(OFabric,"DENIM")==0)

{

if(strcmp(OType,"TROUSER")==0)

OPrice = 1500;

else if(strcmp(OType,"JACKET")==0)OPrice=2500;

}

else

{

if(strcmp(OType,"TROUSER")==0) Price=1500-1500*0.25;

else if(strcmp(OType,"JACKET")==0) Price=2500-2500*0.25;

}

}

public:

Outfit()

strcpy(OCode,"NOT ASSIGNED");

strcpy(OType,"NOT ASSIGNED");

strcpy(OFabric,"NOT ASSIGNED");

OSize=0; OPrice=0;

}

void Input()

{

cout<"Enter code";

gets(OCode);

cout<<"\nEnter type:";

gets(OType); cout<<"\nEnter Size:";

cin>>OSize;

cout<<"\nEnter Material";

gets(OFabric); cout<<"\nEnter Price:";

cin>>OPrice; InitPrice();

}

void Display()

{

cout<<"\nCode:"<<OCode<<endl;

cout<<"\nType:"<<OType<<endl;

cout<<"\nSize:"<<OSize<<endl;

cout<<"\nMaterial:"<<OFabric<<endl;

cout<<"\nPrice:"<<OPrice<<endl;

}

};

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...