Question: Write the following 3 functions: (1) menu() display the menu with options for adding a blog, displaying all blogs, and quitting. (2) addBlog(blog, numBlogs) ask

Write the following 3 functions:

(1) menu() display the menu with options for adding a blog, displaying all blogs, and quitting.

(2) addBlog(blog, numBlogs) ask user to input from keyboard the 6 member data items. Read those values into local variables. Call setBlog method to add the new blog entry to the blog array. Add 1 to numBlogs.

(3) displayBlogs(blog, numBlogs) loop through numBlogs to print each blog entry to a separate line. Add a heading above the blog entries. Use formatting (setw, setfill, left, right) to align columns and display leading spaces and zeroes (where appropriate).

Here is my code:

Main.cpp:

#include #include "Blog.h" using namespace std; const int MAX_BLOGS =100;

int main() { Blog blog[MAX_BLOGS]; int numBlogs=0; int choice=0;

do { menu(); cin >> choice; switch (choice) { case 1: //Add blog addBlog( ); break;

case 2: // display blog displayBlogs( ); break; case 3: // Say goodbye cout<< "Goodbye"<

return 0; }

Blog.h:

#include using namespace std;

class Blog { private: string authorFirst,authorLast,content; int day, month, year; public: Blog(); void setBlog(string,string,string, int, int, int); string getAuthorFirst()const; string getAuthorLast() const; string getContent() const; int getDay() const; int getMonth() const; int getYear() const;

};

Blog.cpp:

#include "Blog.h"

Blog::Blog() { authorFirst=""; authorLast=""; content=""; month=0; day=0; year=0; }

void Blog::setBlog(string authorFirstIn,string authorLastIn,string contentIn, int monthIn, int dayIn, int yearIn) {

authorFirst=authorFirstIn; authorLast=authorLastIn; content=contentIn; month=monthIn; day=dayIn; year=yearIn; }

string Blog::getAuthorFirst()const { return authorFirst; }

string Blog::getAuthorLast() const { return authorLast; }

string Blog::getContent() const { return content; }

int Blog::getDay() const { return day; }

int Blog::getMonth() const { return month; }

int Blog::getYear() const { return year; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!