Write Following 3 Functions 1 Menu Display Menu Options Adding Blog Displaying Blogs Quitt Q43840547
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 keyboardthe 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 toprint each blog entry to a separate line. Add a heading above theblog entries. Use formatting (setw, setfill, left, right) to aligncolumns and display leading spaces and zeroes (whereappropriate).
Here is my code:
Main.cpp:
#include <iostream>
#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”<<endl;
break;
default: // INVALID
cout<< “INVALID choice” <<endl;
}
} while (choice !=3);
return 0;
}
Blog.h:
#include<iostream>
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,stringauthorLastIn,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;
}
Expert Answer
Answer to Write the following 3 functions: (1) menu() – display the menu with options for adding a blog, displaying all blogs, a…
OR