1 / 110

XII CBSE Previous Year Question Paper

XII CBSE Previous Year Question Paper. QUESTION NO 2 (c) 4 Marks. (c) Define a class named ADMISSION in C++ with the following descriptions : Delhi 2006 4 Private members : AD_NO integer (Ranges 10 - 2000) NAME Array of characters(String) CLASS Character FEES Float

Télécharger la présentation

XII CBSE Previous Year Question Paper

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. XII CBSE Previous Year Question Paper QUESTION NO 2 (c) 4 Marks

  2. (c) Define a class named ADMISSION in C++ with the following descriptions : Delhi 2006 4 Private members : AD_NO integer (Ranges 10 - 2000) NAME Array of characters(String) CLASS Character FEES Float Public Members : • Function Read_Data( ) to read an object of ADMISSION type • Function Display( ) to display the details of an object • Function Draw-Nos( ) to choose 2 students randomly. And display the details. Use random function to generate admission nos. to match with AD_NO.

  3. (c) class ADMISSION { int AD_NO; char NAME[20]; //or any constant size char CLASS; float FEES; public: void Read_Data() { do { cin>>AD_NO; }while (AD_NO<10 || AD_NO>2000);

  4. gets(NAME); cin>>CLASS; cin>>FEES; } void Display() { cout<<AD_NO; cout<<NAME; cout<<CLASS; cout<<FEES; }

  5. void Draw_Nos(); }; (1 mark for proper syntax of class definition with correct class name and a semicolon to end the class definition) (1 mark for proper declaration of private members) (1 mark for proper definition of Read_Data()) (1 mark for proper definition of Display()) Note: No marks should be deducted for Not checking the range for AD_NO Not declaring or defining Draw_Nos(). (Mentioned as Draw- Nos() in the question paper)

  6. (c) Define a class named HOUSING in C++ with the following descriptions : Outside Delhi 2006 4 Private members REG_NO integer(Ranges 10 - 1000) NAME Array of characters(String) TYPE Character COST Float

  7. (c) Define a class named HOUSING in C++ with the following descriptions : Outside Delhi 2006 4 Public Members • Function Read_Data() to read an object of HOUSING type • Function Display() to display the details of an object • Function Draw_Nos()to choose and display the details of 2 houses selected randomly from an array of 10 objects of type HOUSING. Use random function to generate the registration nos. to match with REG_NO from the array.

  8. (c) class HOUSING { int REG_NO; char NAME[20]; char TYPE; float COST; public: void Read_Data(); void Display(); void Draw_Nos(HOUSING S); };

  9. (c) void HOUSING::Read_Data() { cin>>REG_NO; //Validation not required cin>>NAME; //OR gets(NAME); cin>>TYPE; cin>>COST; } void HOUSING::Display() { cout<<REG_NO<<NAME<<TYPE<<COST<<endl; }

  10. (c) void HOUSING::Draw_Nos();//Ignore (1/2 mark for proper syntax of class definition with correct class name and a semicolon to end the class definition) (1/2 mark for mentioning the proper visibility modes (private / public)) (1 mark for proper declaration of private data members)

  11. (1 mark for proper definition of Read_Data() with user entry for data members OR declaring a local object and entering the values of data members of this object ) (1 mark for proper definition of Display()) Note: As language of Third part of this question has ambiguity, it is required to be ignored. Moreover, if anyone has partially attempted the third part (i.e., Draw_nos function) and not attempted/not correctly attempted Read/Display function, he/she should be given 2 Marks for Third part taking into consideration the marks for this question should not exceed the max. marks allocated (i.e. 4 marks) to this question 2 (c).

  12. (c) Define a class Travel in C++ with the description given below : Delhi 2007 4 Private Members : T_Code of type string No_of_Adults of type integer No_of_Children of type integer Distance of type integer TotalFare of type float

  13. (c) Define a class Travel in C++ with the description given below : Delhi 2007 4 Public Members : • A constructor to assign initial values as follows : T_Code with the word “NULL” No_of_Adults as 0 No_of_Children as 0 Distance as 0 TotalFare as 0

  14. (c) Define a class Travel in C++ with the description given below : Delhi 2007 4 • A function AssignFare( ) which calculates and assigns the value of the data member TotalFare as follows : For each Adult Fare (Rs) For Distance (Km) 500 >=1000 300 <1000 & >=500 200 <500

  15. (c) Define a class Travel in C++ with the description given below : Delhi 2007 4 For each Child the above Fare will be 50% of the Fare mentioned in the above table. For example : If Distance is 750, No_of_Adults = 3 and No_of_Children = 2 Then TotalFare should be calculated as No_of_Adults * 300 + No_of_Children * 150 i.e. 3 * 300 + 2 * 150 = 1200

  16. (c) Define a class Travel in C++ with the description given below : Delhi 2007 4 • A function EnterTraveK ( ) to input the values of the data members T_Code, No_of_Adults, No_of_Children and Distance; and invoke the AssignFare( ) function. • A function ShowTraveK) which displays the content of all the data members for a Travel.

  17. (c) class Travel { char TCode[5]; //OR char *Tcode; int No_of_Adults; int No_of_Children; int Distance; float TotalFare; public: Travel(); void AssignFare(); void EnterTravel(); void ShowTravel(); };

  18. Travel::Travel() { strcpy(TCode,”NULL”);// OR TCode[0]=’\0’ OR strcpy(TCode,”\0”) // OR TCode=NULL if TCode is declared as char pointer No_of_Adults = 0; No_of_Children = 0; Distance = 0; TotalFare = 0; }

  19. void Travel::AssignFare() { if(Distance>=1000) TotalFare = 500*No_of_Adults+250*No_of_Children; else if (Distance >= 500) TotalFare = 300*No_of_Adults+150*No_of_Children; else TotalFare = 200*No_of_Adults+100*No_of_Children; }

  20. void Travel::EnterTravel() { gets(TCode); // or cin >> TCode; cin>>No_of_Adults>>No_of_Children>>Distance; AssignFare(); } void Travel::ShowTravel() { cout<<TCode<<No_of_Adults<<No_of_Children <<Distance<<TotalFare<<endl; }

  21. (½ Mark for correct syntax of class header) (½ Mark for correct declaration of data members) (1 Mark for correct definition of constructor) (1 Mark for checking all three conditions and calculating TotalFare in AssignFare( )) (½ Mark for correct EnterTravel( ) with proper invocation of AssignFare( )) (½ Mark for displaying all data Members including TotalFare inside ShowTravel( ))

  22. (c) Define a class Tour in C++ with the description given below : Outside Delhi 2007 4 Private Members : TCode of type string NoofAdults of type integer NoofKids of type integer Kilometres of type integer TotalFare of type float

  23. (c) Define a class Tour in C++ with the description given below : Outside Delhi 2007 4 Public Members : • A constructor to assign initial values as follows : TCode with the word “NULL” NoofAdults as 0 NoofKids as 0 Kilometres as 0 TotalFare as 0

  24. (c) Define a class Tour in C++ with the description given below : Outside Delhi 2007 4 • A function AssignFare ( ) which calculates and assigns the value of the data member TotalFare as follows For each Adult Fare(Rs) For Kilometres 500 >=1000 300 <1000&>=500 200 <500

  25. (c) Define a class Tour in C++ with the description given below : Outside Delhi 2007 4 For each Kid the above Fare will be 50% of the Fare mentioned in the above table For example : If Kilometres is 850, NoofAdults = 2 and NoofKids = 3 Then TotalFare should be calculated as NumofAdults * 300 + NoofKids * 150 i.e. 2*300 + 3*150=1050

  26. (c) Define a class Tour in C++ with the description given below : Outside Delhi 2007 4 • A function EnterTour( ) to input the values of the data members TCode, NoofAdults, NoofKids and Kilometres; and invoke the Assign Fare( ) function. • A function ShowTour( ) which displays the content of all the data members for a Tour.

  27. (c) class Tour { char TCode[10]; //OR char *Tcode; int NoofAdults; int NoofKids; int Kilometres; float TotalFare; public: Tour() { strcpy(TCode,”NULL”); //OR TCode[0]=’\0’OR strcpy(TCode,”\0”)

  28. //OR TCode=NULL if TCode is declared as char pointer NoofAdults = 0; NoofKids = 0; Kilometres = 0; TotalFare = 0; } void AssignFare(); void EnterTour(); void ShowTour(); };

  29. void Tour::AssignFare() { if(Kilometres>=1000) TotalFare = 500*NoofAdults+250*NoofKids; else if (Kilometres >= 500) TotalFare = 300*NoofAdults+150*NoofKids; else TotalFare = 200*NoofAdults+100*NoofKids; }

  30. void Tour::EnterTour() { gets(TCode); // or cin >> TCode; cin>>NoofAdults>>NoofKids>>Kilometres; AssignFare( ); } void Tour::ShowTour() { cout<<TCode<<NoofAdults<<NoofKids<<Kilometres<<TotalFare<<endl; }

  31. (½ Mark for correct syntax for class header) (½ Mark for correct declaration of data members) (1 Mark for correct definition of constructor) (½ Mark for condition checking in AssigFare()) (½ Mark for calculation of correct TotalFare for each condition) (½ Mark for correct EnterTour() with proper invocation of AssignFare()) (½ Mark for displaying all data Members including TotalFare inside ShowTour())

  32. (c) Define a class Garments in C++ with the following descriptions: Delhi 2008 4 Private Members: GCode of type string GType of type string GSize of type integer GFabric of type string GPrice of type float A function Assign ( ) which calculates and assigns the value of GPrice as follows

  33. (c) Define a class Garments in C++ with the following descriptions: Delhi 2008 4 For the value of GFabric as “COTTON”, GType GPrice(Rs) TROUSER 1300 SHIRT 1100 For GFabric other than “COTTON” the above mentioned GPrice gets reduced by 10%.

  34. (c) Define a class Garments in C++ with the following descriptions: Delhi 2008 4 Public Members: A constructor to assign initial values of GCode, GType and GFabric with the word “NOT ALLOTTED” and GSize and GPrice with 0 A function Input ( ) to input the values of the data members GCode, GType, GSize and GFabric and invoke the Assign ( ) function. A function Display ( ) which displays the content of all the data members for a Garment.

  35. Ans: class Garments { char GCode[10]; char GType[10]; int GSize; char GFabric[10] ; float GPrice; void Assign( ) ;

  36. public: Garments( ) { strcpy(GCode,”NOT ALLOTTED”) ; strcpy(GType,”NOT ALLOTTED”) ; strcpy (GFabric, “NOT ALLOTTED”) ; GSize=0; GPrice=0; } void Input( ) ; void Display( ) ; } ;

  37. void Garments::Assign( ) { if (strcmp(GFabric,“COTTON”)==0) //if (!strcmp(GFabric, “COTTON”)) { if (strcmp(GType,“TROUSER”) ==0) GPrice=1300; else if (strcmp(GType,“SHIRT”)==0) GPrice=1100; }

  38. else { if (strcmp(GType,”TROUSER”) = =0) GPrice=1300*0.9; // 10% reduction else if (strcmp(GType,“SHIRT”)= =0) GPrice=1100*0.9; // 10% reduction } } void Garments::Input( ) { gets(GCode) ; // or cin >> GCode; gets(GType) ; // or cin >> GType; cin>>Gsize;

  39. gets(GFabric) ;// or cin >> GFabric; Assign( ) ; } void Garments::Display( ) { cout<<GCode<<GType<<GSize<<GFabric<<GPrice<<endl; } (½ Mark for correct syntax for class header) (½ Mark for correct declaration of data members) (½ Mark for correct definition of constructor)

  40. (1 Mark for correct definition of Assign( )) (1 Mark for correct definition of Input( ) with proper invocation of Assign( ) function) (½ Mark for correct definition of Display( )) NOTE: Deduct % Mark if Assign( ) is not invoked properly inside Input( ) function

  41. (c) Define a class Clothing in C++ with the following descriptions: Outside Delhi 2008 4 Private Members: Code of type string Type of type string Size of type integer Material of type string Price of type float A function Calc_Price( ) which calculates and assigns the value of Price as follows:

  42. (c) Define a class Clothing in C++ with the following descriptions: Outside Delhi 2008 4 For the value of Material as “COTTON” : Type Price (Rs.) TROUSER 1500 SHIRT 1200 For Material other than “COTTON” the above mentioned Price gets reduced by 25%.

  43. (c) Define a class Clothing in C++ with the following descriptions: Outside Delhi 2008 4 Public Members: A constructor to assign initial values of Code, Type and Material with the word “NOT ASSIGNED” and Size and Price with 0. A function Enter( ) to input the values of the data members Code, Type, Size and Material and invoke the CalcPrice( ) function. A function Show( ) which displays the content of all the data members for a Clothing

  44. Ans: class Clothing • { • char Code[25]; • char Type[25]; • int Size; • char Material[30]; • float Price; • Public: • Clothing() ; • void Calc_Price() ; • void Enter() ; • void Show() ; • };

  45. Clothing::Clothing() { strcpy(Code,”NOT ASSIGNED”); strcpy(Type,”NOT ASSIGNED”); Size=0; strcpy (Material, “NOT ASSIGNED”); Price=0; }

  46. void Clothing:: Calc_Price() { if (strcmp(Type, “TROUSER”) ==0 && strcmp (Material,“COTTON”)==0) Price=1500; else if (strcmp(Type, “SHIRT”) ==0 && strcmp(Material,”COTTON”)==O) Price=1200; else if (strcmp(Type, “TROUSER”) ==0 && strcmp(Material,”COTTON”)!=O) Price=1500*0.75;

  47. void Clothing:: Calc_Price() { if (strcmp(Type, “TROUSER”) ==0 && strcmp (Material,“COTTON”)==0) Price=1500; else if (strcmp(Type, “SHIRT”) ==0 && strcmp(Material,”COTTON”)==O) Price=1200; else if (strcmp(Type, “TROUSER”) ==0 && strcmp(Material,”COTTON”)!=O) Price=1500*0.75; else if (strcmp(Type,”SHIRT”)==0) &&

  48. strcmp(Material,”COTTON”)!= 0) Price=1200*0.75; } void Clothing::Enter() { gets(Code) ; // or cin >> Code; gets(Type) ; // or cin >> Type; cin>>Size; gets(Material) ;// or cin >> Material; Calc_Price() ; }

  49. void Clothing::Show() { cout<<Code<<Type<<Size<<Material<<Price<<endl; } (½ Mark for correct syntax for class header) (½ Mark for correct declaration of data members) (½ Mark for correct definition of function Calc_price()) (½ Mark for constructor) (1 Mark for calculation of correct Price for each condition)

  50. (½ Mark for correct Enter() with proper invocation of Calc_Price()) (½ Mark for displaying all data Members in function Show())

More Related