This is an assignment I am attempting to work on where I am attempting to create a program that asks for a books title, its author, and its date of publication, before displaying all inputs at the end. My primary obstacle is trying to get everything to display in a somewhat decent way. preferably in an array with text like "written by" in between. Right now it just displays all the data separately in lines. Please let me know if you need any additional information.
#include <string>
#include <vector>
using namespace std;
int main ()
{
int i=0;
int n;
string bookTitle;
string bookAuthor;
string bookDate;
vector<string> Title;
vector<string> Author;
vector<string> Date;
cout << "Enter the Number of Books: ";
cin >> n;
cin.ignore();
for (i; i < n; i++)
{
cout << "Type the Book's Title: ";
getline (cin, bookTitle);
Title.push_back(bookTitle);
cout << "Type the Book's Author: ";
getline (cin, bookAuthor);
Author.push_back(bookAuthor);
cout << "Type the Book's Date: ";
getline (cin, bookDate);
Date.push_back(bookDate);
}
for (auto it = Title.begin(); it != Title.end(); ++it) {
cout << *it <<endl;
}
for (auto it = Author.begin(); it != Author.end(); ++it) {
cout << *it <<endl;
}
for (auto it = Date.begin(); it != Date.end(); ++it) {
cout << *it <<endl;
}
return 0;
}