This document defines 4 classes:
1. BOOK with private data like book number and public functions to read and calculate total cost.
2. Batsman with private data like code and runs, and public functions to read, calculate batting average, and display data.
3. Student with private data like admission number and marks, and public functions to read data and calculate average.
4. Stack with private data like size and top, and public constructor, destructor, push, and pop functions to implement stack operations.
Download as DOC, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
51 views
C++ Problems
This document defines 4 classes:
1. BOOK with private data like book number and public functions to read and calculate total cost.
2. Batsman with private data like code and runs, and public functions to read, calculate batting average, and display data.
3. Student with private data like admission number and marks, and public functions to read data and calculate average.
4. Stack with private data like size and top, and public constructor, destructor, push, and pop functions to implement stack operations.
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1
1.
Define a class BOOK with the following specifications :
Private members of the class BOOK are BOOK NO integer type BOOKTITLE 20 characters !I"E float #price per copy$ TOT%L&"O'T#$ % f(nction to calc(late the total cost for N n()*er of copies where N is passe+ to the f(nction as arg()ent. Public members of the class BOOK are IN,T#$ f(nction to rea+ BOOK&NO. BOOKTITLE- !I"E ,!".%'E#$ f(nction to as/ the (ser to inp(t the n()*er of copies to *e p(rchase+. It in0o/es TOT%L&"O'T#$ an+ prints the total cost to *e pai+ *y the (ser. 2. Define a class *ats)an with the following specifications: Private members: *co+e 1 +igits co+e n()*er *na)e 20 characters innings- noto(t- r(ns integer type *ata0g it is calc(late+ accor+ing to the for)(la 2 *ata0g 3r(ns4#innings5noto(t$ calca0g#$ 6(nction to co)p(te *ata0g Public members: rea++ata#$ 6(nction to accept 0al(e fro) *co+e- *na)e- innings- noto(t an+ in0o/e the f(nction calca0g#$ +isplay+ata#$ 6(nction to +isplay the +ata )e)*ers on the screen 7. Define a class !EO!T with the following specification: Private members : a+no 1 +igit a+)ission n()*er na)e 20 characters )ar/s an array of 8 floating point 0al(es a0erage a0erage )ar/s o*taine+ 9ET%:9#$ a f(nction to co)p(te the a0erage o*taine+ in fi0e s(*;ect Public members: !E%DIN6O#$ f(nction to accept 0al(es for a+no- na)e- )ar/s. In0o/e the f(nction 9ET%:9#$ 1. "reate a class 'T%"K with the following specifications to i)ple)ent the stac/ operations: Private members 'tc/<'I=E> 'i?e of stac/ Top top ele)ent of stac/ Public members 'T%"K#$ "onstr(ctor f(nction @'T%"K#$ Destr(ctor f(nction (sh#$ 6(nction to p(sh ele)ents onto the stac/. op#$ 6(nction to pop ele)ents fro) the stac/.