Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Which cost is greater: replacement cost or actual cash value? Why?

Answered: 1 week ago

Question

6. Have you used solid reasoning in your argument?

Answered: 1 week ago