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
1.2k views
in C Programming by (80 points)
recategorized by

Define a class AUTHOR with the following specifications:

Private members of the class BOOK are:

BOOK NO integer type

BOOKTITLE 20 characters

PRICE float (price per copy)

Define functions:

INPUT() : function to read BOOK_NO,BOOKTITLE, PRICE

PURCHASE(): function to ask the user to input the number of copies to be purchased.

TOTAL_COST() : A function to calculate the total cost for N number of copies where N is passed to the function as argument.

Please log in or register to answer this question.

1 Answer

0 votes
by (38.0k points)

#include <iostream> 

using namespace std; 

class Author 

public: 

int number_copyes = 0; 

void purchased()  

cout << "Input the number of copies to be purchased: "; 

cin >> number_copyes; 

float total_cost()  

return number_copyes * price_float; 

void input() 

cout << "Enter book_no: "; 

cin >> book_no; 

cout<<"Enter book_tittle: "; 

cin >> book_tittle; 

cout << "Enter price book: "; 

cin >> price_float;

private: 

int book_no; 

char book_tittle [20]; 

double price_float; 

}; 

int main() 

Author example; 

example.input(); 

example.purchased(); 

cout << "Total cost: " << example.total_cost(); 

return 0; 

}

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

...