Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The following class interface, implementation and main driver have syntax errors. Your task is to find and fix the bugs. A bug free program will

The following class interface, implementation and main driver have syntax errors. Your task is to find and fix the bugs. A bug free program will have the following expected output Book Class Test Book ID: 75632 Title: Joy of C++ Price: $34.49 Quantity: 250 bObj ID: 9999

#include

#include

#include

using namespace std;

//Class Interface

class Book{

private:

int id;

string title;

double price;

int qty;

void setID(int);

void setTitle(string);

void setPrice(double);

void setQty(int);

void getID() const;

void print() const;

Book(int, string = "No Title", double = 10.95, int = 10);

}

int main ()

{

cout << " Book Class Test ";

Book bObj, cObj(75632, "Joy of C++", 34.49, 250);

cObj.print();

cout << " bObj ID: " << bObj.getID();

return 0;

}

//Class Implementation

void Book::setID(int i){

id = i;

return id;

}

void Book::setTitle(string t){

title = t;

}

void Book::setPrice(double p){

if(p <= 0){

price = 0;

}

else{

price = p;

}

void Book::setQty(int q){

if(q <= 0){

qty = 0;

}

else{

qty = q;

}

}

int Book::getID() const

return id;

}

void Book::print(){

cout << " Book ID: " << id;

cout << " Title: " << title;

cout << " Price: $" << price;

cout << " Quantity: " << qty;

}

Book::Book(int i = 9999, string t, double p, int q){

setID(i);

setTitle(t);

setPrice(p);

setQty(q);

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Sham Navathe,Ramez Elmasri

5th Edition

B01FGJTE0Q, 978-0805317558

More Books

Students also viewed these Databases questions

Question

How do writers decide what to cover in a trip report?

Answered: 1 week ago

Question

107 MA ammeter 56 resistor ? V voltmeter

Answered: 1 week ago

Question

Generally If Drug A is an inducer of Drug B , Drug B levels will

Answered: 1 week ago

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago