Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need a pseudocode, flowchart and UML Diagram: #include Date.h #include using namespace std; // Start of main void bubbleSort(Date date[], int n)//is an array

I need a pseudocode, flowchart and UML Diagram:

#include "Date.h"

#include

using namespace std;

// Start of main

void bubbleSort(Date date[], int n)//is an array of dates and is the size of the array

{

int i, j;

for (i = 0; i < n - 1; i++)

// Last i elements are already in place

for (j = 0; j < n - i - 1; j++)

if (date[j] > date[j + 1])

{

Date temp = date[j];

date[j] = date[j + 1];

date[j + 1] = temp;

}

}

int main() {

// Declare arrays and variables

const int SIZE = 7; // Size of array elements

const int COUNT = 6; // Number of holidays

Date weekDays[SIZE]; // Weekday array

Date holidays[COUNT]; // Holiday array

string holidaysDescription[COUNT];

int year = 0;

Date easterSunday(04, 01, 2018); // Easter Sunday

holidays[0] = easterSunday;

holidaysDescription[0] = "Easter Sunday";

Date mothersDay(05, 13, 2018); // Mother's Day

holidays[1] = mothersDay;

holidaysDescription[1] = "Mother's Day";

Date memorialDay(05, 28, 2018); // Memorial Day

holidays[2] = memorialDay;

holidaysDescription[2] = "Memorial Day";

Date fathersDay(06, 17, 2018); // Fathers Day

holidays[3] = fathersDay;

holidaysDescription[3] = "Father's Day";

Date independenceDay(07, 04, 2018); // Independence Day

holidays[4] = independenceDay;

holidaysDescription[4] = "Independence Day";

// Prompt the user for current year

cout << "Please enter the current year: ";

cin >> year;// Read in year

cout << " ";

// Search for the date of Thanksgiving and add it to

// the holiday array

Date currentYear = { 1,1,2018 };

Date giveThanks = currentYear.thanksGiving();

holidays[5] = giveThanks;

holidaysDescription[5] = "Thanksgiving";

bubbleSort(holidays, COUNT);//Sort the list of the array

cout << " The holidays are sorted by date: ";

for (int index = 0; index < COUNT; index++)

{

// Display the holiday

int day = holidays[index].weekday();

cout << holidaysDescription[index] << " is on " << holidays[index] << " which falls on a ";

// Display the day

switch (day) {

case 0: cout << "Sunday" << endl; break;

case 1: cout << "Monday" << endl; break;

case 2: cout << "Tuesday" << endl; break;

case 3: cout << "Wednesday" << endl; break;

case 4: cout << "Thursday " << endl; break;

case 5: cout << "Friday" << endl; break;

case 6: cout << "Saturday " << endl; break;

}

}

cout << " ";

cout << "The following holidays land on a season 0=winter, 1=spring, 2=summer and 3=fall for the northern hemisphere." << endl;

for (int index = 0; index < COUNT; index++)

{

cout << holidays[index] << " is in season " << holidays[index].season() << endl;

}

system("pause");

return 0;

}

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

Presentations Approaches to Conveying Information

Answered: 1 week ago