Sarthaks Test
0 votes
692 views
in C Programming by (82 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 (39.5k 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; 

}

Related questions

0 votes
1 answer
0 votes
1 answer
asked Feb 20, 2020 in Computer by Santanu01 (51.0k points)
0 votes
1 answer
0 votes
1 answer
asked Feb 20, 2020 in Computer by Santanu01 (51.0k points)
0 votes
1 answer
asked Feb 20, 2020 in Computer by Santanu01 (51.0k points)

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

...