Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class Book {
- public:
- Book MyBook();
- void setBookTitle(string i) {
- bookTitle = i;
- }
- string getBookTitle() {
- return bookTitle;
- }
- void setAuthor(string j) {
- author = j;
- }
- string getAuthor() {
- return author;
- }
- void setPrice(double k) {
- price = k;
- }
- double getPrice() {
- return price;
- }
- void setAmountOfCopies(int l) {
- amountOfCopies = l;
- }
- int getAmountOfCopies() {
- return amountOfCopies;
- }
- double CalcSalePrice() {
- int discount;
- cout << "Please enter discount percentage: ";
- cin >> discount;
- price = price - (price * (discount / 100));
- return price;
- }
- int BookSold() {
- int soldCopies;
- cout << "Please enter the amount of copies sold: ";
- cin >> soldCopies;
- amountOfCopies = amountOfCopies - soldCopies;
- return 0;
- }
- void DisplayInfo() {
- cout << "Title: " << bookTitle << endl;
- cout << "Author: " << author << endl;
- cout << "Price: R" << price << endl;
- cout << "Copies Left: " << amountOfCopies << endl;
- }
- private:
- //book title
- string bookTitle;
- //name of the author
- string author;
- //price of the book
- double price;
- //amount of copies in stock
- int amountOfCopies;
- };
- void bookInput()
- {
- string title, author;
- int copies;
- double price;
- Book HarryPooter;
- cout << "Please enter the title of the Book: ";
- getline(cin, title);
- HarryPooter.setBookTitle(title);
- cout << "Please enter the author: ";
- getline(cin, author);
- HarryPooter.setAuthor(author);
- cout << "Please enter the price: R";
- cin >> price;
- HarryPooter.setPrice(price);
- cout << "Please enter the amount of copies in stock: ";
- cin >> copies;
- HarryPooter.setAmountOfCopies(copies);
- }
- int main()
- {
- bookInput();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement