Question

This assignment requires using C++ language Your program will be creating 10 library books. Each library...

This assignment requires using C++ language

Your program will be creating 10 library books. Each library book will have title, author and publishing year. Each library book will be stored as a structure and your program will have an array of library books (an array of structures).

You will create a corresponding array of book genres: Mystery, Romance, Fantasy, Technology, Children, etc. If the first element of the array is storing information about a book titled : "More about Paddington", then the corresponding first element of book genre would indicate 'Children'.

The user of your program should be able to select what they want to do from a menu of the following things and your program needs to do what the menu selection indicates:

* Print the entire list of library books (including the title, author, publishing year and book genre)

* Display a count of how many books exist per genre

* Find all books where the publishing year is greater than the year they put in

* Print the titles of the books where the Genre may be indicated by a 'C' for Children, or 'M' for Mystery

  1. Create an algorithm.
  2. Program and save as LibraryBooksYourName.cpp. Make sure to include the algorithm and comment your code! Make sure you meet all the requirements specified above.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<iostream>
#include <stdlib.h>
#include<time.h>
#include<string.h>
using namespace std;
struct Books
{
char title[50];
char author[50];
int year;
} books[10];
char Genre[10][50];
void insertbooks()
{
srand(time(0));
for(int i=0;i<10;i++)
{
char t[]="Book ";t[5]=(char)i+48;
strcpy(books[i].title,t);
strcpy(books[i].author,"Author");
books[i].year=(rand() % (2015 -1900 + 1))+1900 ;
}
}

int main()
{
int n,i;
insertbooks();
cout<<"Menu"<<endl;
cout<<"1.Books List"<<endl;
cout<<"2.No of books per Genre"<<endl;
cout<<"3.Search books by Year"<<endl;
cout<<"4.Book list by Genere"<<endl;
cout<<"5.Exit"<<endl;
cout<<"Enter your choice:";
cin>>n;
switch(n)
{
case 1:
for(i=0;i<10;i++)
cout<<books[i].title<<endl;
break;
case 2:
case 3:
int year;
cout<<"Enter Year";
cin>>year;
for(i=0;i<10;i++)
if(year>=books[i].year)
cout<<books[i].title<<endl;
break;
  

}
return 0;
}
  


Add a comment
Know the answer?
Add Answer to:
This assignment requires using C++ language Your program will be creating 10 library books. Each library...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • please use C++ write a program to read a textfile containing a list of books. each...

    please use C++ write a program to read a textfile containing a list of books. each line in the file has tile, ... Question: Write a program to read a textfile containing a list of books. each line in the file has tile, ..... write a program to read a textfile containing a list of books. each line in the file has tile, ... Question: Write a program to read a textfile containing a list of books. Each line in...

  • Write a C program to create a list of books details. The details of a book...

    Write a C program to create a list of books details. The details of a book include title, author, publisher, publishing year, no. of pages , price Perform the following with respect to the list of books created Display all the details of books written by a given author. Sort the details of books in the increasing order of price. Display the details of books published by a given publisher in a given year. Sort the list of books in...

  • // C programming Create a system managing a mini library system. Every book corresponds to a...

    // C programming Create a system managing a mini library system. Every book corresponds to a record (line) in a text file named "mylibrary.txt". Each record consists of 6 fields (Book ID, Title, Author, Possession, checked out Date, Due Date) separated by comma: No comma '', "in title or author name. This mini library keeps the record for each book in the library. Different books can share the book "Title". But the "Book ID" for each book is unique. One...

  • Download the library.xml file. The root element is CATALOG and contains a series of BOOK elements,...

    Download the library.xml file. The root element is CATALOG and contains a series of BOOK elements, each of which represents a single BOOK. Each BOOK element has a number of child elements such as AUTHOR, TITLE, GENRE, PRICE and so on. Python Language 3.8 Add comments for each line Thank you Write a program to read the file and print out the following information with an appropriate message: 1. (40 points) Write a function called display_book that prints the title,...

  • Write a C++ program that asks for the following information about a book order from the...

    Write a C++ program that asks for the following information about a book order from the console: • Title • Author • ISBN (hint: careful about what data type to use - validate 9 or 13 characters) • Price (validate number < 400) • Quantity (number of books to purchase – validate > 0 and < 100) • Fiction/Non-Fiction (‘N’ or ‘F’ - validate) • Genre (‘R’ romance, ‘D’ drama, ‘M’ mystery – validate) Make use of the following data...

  • You need to program a simple book library system. There are three java classes Book.java   //...

    You need to program a simple book library system. There are three java classes Book.java   // book object class Library.java   //library class A2.java //for testing The Book.java class represents book objects which contain the following fields title: a string which represents the book title. author: a string to hold the book author name year: book publication year isbn: a string of 10 numeric numbers. The book class will have also 3 constructors. -The default no argument constructor - A constructor...

  • please Code in c++ Create a new Library class. You will need both a header file...

    please Code in c++ Create a new Library class. You will need both a header file and a source file for this class. The class will contain two data members: an array of Book objects the current number of books in the array Since the book array is moving from the main.cc file, you will also move the constant array size definition (MAX_ARR_SIZE) into the Library header file. Write the following functions for the Library class: a constructor that initializes...

  • In this assignment you will implement software for your local library. The user of the software...

    In this assignment you will implement software for your local library. The user of the software will be the librarian, who uses your program to issue library cards, check books out to patrons, check books back in, send out overdue notices, and open and close the library. class Calendar We need to deal with the passage of time, so we need to keep track of Java. Declare this variable as private int date within the class itself, not within any...

  • Subject: Java Program You are writing a simple library checkout system to be used by a...

    Subject: Java Program You are writing a simple library checkout system to be used by a librarian. You will need the following classes: Patron - A patron has a first and last name, can borrow a book, return a book, and keeps track of the books they currently have checked out (an array or ArrayList of books). The first and last names can be updated and retrieved. However, a patron can only have up to 3 books checked out at...

  • Objectives: The main objective of this assignment is checking students’ ability to implement membership functions. After...

    Objectives: The main objective of this assignment is checking students’ ability to implement membership functions. After completing this assignment, students will be able to:  implement member functions  convert a member function into a standalone function  convert a standalone function into a member function  call member functions  implement constructors  use structs for function overloading Problem description: In this assignment, we will revisit Assignment #1. Mary has now created a small commercial library and has managed...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT