Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(using c++ visual studio) Need to create a class, need help with separating what

ID: 3749405 • Letter: #

Question

(using c++ visual studio) Need to create a class, need help with separating what goes into header, struct with setters and getters, and function.

Design and implement a class dayType that implements the day of theweekinaprogram.Theclass dayTypeshouldstoretheday,such as Sun for Sunday. The program should be able to perform the follow- ing operations on an object of type dayType: a. Set the day. b. Print the day. c. Return the day. d. Return the next day. e. Return the previous day. f. Calculate and return the day by adding certain days to the current day. For example, if the current day is Monday and we add 4 days, the day to be returned is Friday. Similarly, if today is Tuesday and we add 13 days, the day to be returned is Monday. g. Add the appropriate constructors.

Explanation / Answer

#include <iostream>

#include <iomanip>

#include <string>

using namespace std;

class daytype

{

string dayofweek[7];

string da;

int count;

public:

daytype()

{

dayofweek[0] = ("mon");

dayofweek[1] = ("tues");

dayofweek[2] = ("wed");

dayofweek[3] = ("thurs");

dayofweek[4] = ("fri");

dayofweek[5] = ("satur");

dayofweek[6] = ("sun");

}

void PrintTheDay()

{

for (int i = 0; i < 7; i++)

cout << (i + 1) << " :" << dayofweek[i] << endl;

}

void getDayofweek()

{

string theday;

cout << "Enter the day" << endl;

getline(cin, theday);

da = theday;

}

void comparetheday()

{

for (int i = 0; i < 7;i++)

if (da == dayofweek[i])

count = i;

}

void PreviousNextDay()

{

if (count >0)

cout << "Previus Day is :" << dayofweek[count - 1] << endl;

else

cout << "Previous Day is :" << dayofweek[6] << endl;

cout << "Today is :" << dayofweek[count] << endl;

if (count < 6)

cout << "Next Day :" << dayofweek[count + 1] << endl;

else

cout << "Next Day :" << dayofweek[0] << endl;

}

int GetTheNumber()

{

int target;

cout << "Enter the Number " << endl;

cin >> target;

return target;

}

void Aftertheday(int TargetDay)

{

int l = TargetDay % 7;

if ((l + count) >= 6)

{

l = (count + l) % 7;

cout << "The day after " << TargetDay << " Day is :" << dayofweek[ l] << endl;

}

else if (l == 0)

cout << "The day after "<< TargetDay <<" Day is :" << dayofweek[count] << endl;

}

};

int main()

{

int target;

daytype dayofweek;

dayofweek.PrintTheDay();

dayofweek.getDayofweek();

dayofweek.comparetheday();

target = dayofweek.GetTheNumber();

dayofweek.PreviousNextDay();

dayofweek.Aftertheday(target);

system("pause");

}

After Running the code :-

1 :mon

2 :tues

3 :wed

4 :thurs

5 :fri

6 :satur

7 :sun

Enter the day 2

Enter the Number 13

Previus Day is :mon

Today is :tues

Next Day :wed

The day after 13 Day is :mon