0% found this document useful (0 votes)
40 views2 pages

Task 4

The document is a C++ program that defines a 'Book' class to manage book details including author, title, publisher, price, and stock position. It allows users to enter book information and check the availability of a specific book title, calculating the total price based on the quantity requested. However, the program contains some logical errors, such as incorrect array indexing and the use of uninitialized array elements.

Uploaded by

Atizaz Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views2 pages

Task 4

The document is a C++ program that defines a 'Book' class to manage book details including author, title, publisher, price, and stock position. It allows users to enter book information and check the availability of a specific book title, calculating the total price based on the quantity requested. However, the program contains some logical errors, such as incorrect array indexing and the use of uninitialized array elements.

Uploaded by

Atizaz Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include<iostream>

#include<string.h>

using namespace std;

class Book{
string author;
string title;
string publisher;
int price;
int stock_position;

public :
Book(){
for(int i=0;i<1;i++){
cout<<"Enter the author Name : ";
cin>>author;
fflush(stdin);
cout<<"Enter the title : ";
cin>>title;
fflush(stdin);
cout<<"Enter the publisher : ";
cin>>publisher;
fflush(stdin);
cout<<"Enter the price of the book : ";
cin>>price;
fflush(stdin);
cout<<"Enter the Number of Books present in Store : ";
cin>>stock_position;
fflush(stdin);

cout<<"________________________________________________________-"<<endl;
}
}
int checklist(string a){
int qu;
for(int i=0;i<3;i++){
if(title == a){

//if(strcmp(title, a)==0){ //strcmp(,) //ABCD


//cout<<"____"<<title[i]<<" "<<a[i]<<"_____";
cout<<"How much Quantity of book, Customer want : ";
cin>>qu;
if(qu<stock_position){
int total=qu*price;
cout<<"Total amount : "<<total<<endl;
exit(0);
}
else{
cout<<"not Available"<<endl;
}
}
else{
return 1;
}
}
}
/* void s_position(int n){
if(n<stock_position){
int total=n*price;
cout<<total;
}
}*/
};

int main(){
Book b[3];
string a;
cout<<"Enter the Title of the Book : ";
cin>>a;
b[1].checklist(a);
b[2].checklist(a);
b[3].checklist(a);
}

You might also like