I am using Microsoft Visual Studios,
Your program will be creating 10 library books. Each library book will have a 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 and display all books where the publishing year is greater than the year user put in
* Print the titles of the books where the Genre may be indicated by a 'C' for Children, or 'M' for Mystery
here is what I have:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
// LibraryBooksNickoleSmith.cpp : This file contains the 'main' function. Program execution begins and ends there.
/*
*******************************************************************************************************************
*****************************************
** Heading Comments:
** Name: Nickole Smith
** Date: 10/3/18
** Purpose : Create an array and structure program for library books.
*******************************************************************************************************************
*******************************
** Algorithm:
** 0. No input from user.
** 1. Create structure and array for book title, author (first and last name), year, and genres.
** 2. Create system to put books in order from users input.
** 3. Output information from users input.
*******************************************************************************************************************
*/
#include "pch.h"
#include <iostream>
using namespace std;
int numBookGenre;
int romance(numBookGenre);
int technology(numBookGenre);
int fantasy(numBookGenre);
int scify(numBookGenre);
int children(numBookGenre);
int thriller(numBookGenre);
int Mystery(numBookGenre);
struct Book
{
char bookTitle;
char authorFirstName;
char authorLastName;
char bookGenre;
char bookYear;
};
void printEes(Book[], int);
int main()
{
int numBooks;
cout << "how many books? \n";
cin >> numBooks;
// create array for books.
Book books[numBooks];
for (int i = 0; i < numBooks; i++) {
cout << "Please enter book title. \n";
cin >> books[i].bookTitle;
cout << "Author's first name. \n";
cin >> books[i].authorFirstName;
cout << "Author's last name. \n";
cin >> books[i].authorLastName;
cout << "What type of genre is the book?";
cin >> books[i].bookGenre;
cout << "What year was it published?";
cin >> books[i].bookYear;
}
printEes(books, numBooks);
void printEes(Book books[], int size)
{
for (int i = 0; i < size; i++) {
cout << books[i].bookTitle << endl;
cout << books[i].authorFirstName << " "
<< books[i].authorLastName << endl;
cout << books[i].bookGenre << endl;
cout << books[i].bookYear << endl;
}
switch (books[i].bookGenre) {
case childrens:
cout << "C ";
case Mystery:
cout << "M ";
case Fantasy:
cout << "F ";
case romance:
cout << "R ";
case Technology:
cout << "Tech ";
}
}
}
|
I keep getting errors and I don't understand.
errors:
Error (active) E0028 expression must have a constant value LibraryBooksNickoleSmith C:\Users\smith\Desktop\CSC - Nikki\LibraryBooksNickoleSmith\LibraryBooksNickoleSmith\LibraryBooksNickoleSmith.cpp 53
Error (active) E0065 expected a ';' LibraryBooksNickoleSmith C:\Users\smith\Desktop\CSC - Nikki\LibraryBooksNickoleSmith\LibraryBooksNickoleSmith\LibraryBooksNickoleSmith.cpp 71
Error (active) E0169 expected a declaration LibraryBooksNickoleSmith C:\Users\smith\Desktop\CSC - Nikki\LibraryBooksNickoleSmith\LibraryBooksNickoleSmith\LibraryBooksNickoleSmith.cpp 96
Error C2131 expression did not evaluate to a constant LibraryBooksNickoleSmith c:\users\smith\desktop\csc - nikki\librarybooksnickolesmith\librarybooksnickolesmith\librarybooksnickolesmith.cpp 53
Error C2601 'printEes': local function definitions are illegal LibraryBooksNickoleSmith c:\users\smith\desktop\csc - nikki\librarybooksnickolesmith\librarybooksnickolesmith\librarybooksnickolesmith.cpp 71
Error C2065 'i': undeclared identifier LibraryBooksNickoleSmith c:\users\smith\desktop\csc - nikki\librarybooksnickolesmith\librarybooksnickolesmith\librarybooksnickolesmith.cpp 79
Error C2065 'childrens': undeclared identifier LibraryBooksNickoleSmith c:\users\smith\desktop\csc - nikki\librarybooksnickolesmith\librarybooksnickolesmith\librarybooksnickolesmith.cpp 81
Error C2131 expression did not evaluate to a constant LibraryBooksNickoleSmith c:\users\smith\desktop\csc - nikki\librarybooksnickolesmith\librarybooksnickolesmith\librarybooksnickolesmith.cpp 81
Error C2131 expression did not evaluate to a constant LibraryBooksNickoleSmith c:\users\smith\desktop\csc - nikki\librarybooksnickolesmith\librarybooksnickolesmith\librarybooksnickolesmith.cpp 84
Error C2065 'Fantasy': undeclared identifier LibraryBooksNickoleSmith c:\users\smith\desktop\csc - nikki\librarybooksnickolesmith\librarybooksnickolesmith\librarybooksnickolesmith.cpp 87
Error C2131 expression did not evaluate to a constant LibraryBooksNickoleSmith c:\users\smith\desktop\csc - nikki\librarybooksnickolesmith\librarybooksnickolesmith\librarybooksnickolesmith.cpp 87
Error C2131 expression did not evaluate to a constant LibraryBooksNickoleSmith c:\users\smith\desktop\csc - nikki\librarybooksnickolesmith\librarybooksnickolesmith\librarybooksnickolesmith.cpp 90
Error C2065 'Technology': undeclared identifier LibraryBooksNickoleSmith c:\users\smith\desktop\csc - nikki\librarybooksnickolesmith\librarybooksnickolesmith\librarybooksnickolesmith.cpp 93
Error C2131 expression did not evaluate to a constant LibraryBooksNickoleSmith c:\users\smith\desktop\csc - nikki\librarybooksnickolesmith\librarybooksnickolesmith\librarybooksnickolesmith.cpp 93