subject

#include #include
using namespace std;

void menu();

class dayType
{
string Wdays[7];
int i;
string day;
string prDay;
string NxtDay;
string AddDays;
public:
dayType(string);
string setday();
string preday();
void Nextday();
string add(int n);
void print();

};
int main()
{
int n;

string d;
menu();
cout <<"Enter the day :";
getline(cin, d);
dayType Da(d);
Da. setday();
Da. preday();
Da. Nextday();

cout <<"Enter the No. of days to add :";
while (!(cin >> n) ||n<0) {
cin. clear();
cin. ignore(999, '\n');
cout <<"Invalid data type! \nPlease enter No. of daysto add again :";

}
Da. add(n);
Da. print();
system("pause");
return 0;

}
dayType::dayType(string) :day(){
Wdays[0] = "Mon";
Wdays[1] = "Tues";
Wdays[2] = "Wednes";
Wdays[3] = "Thurs";
Wdays[4] = "Fri";
Wdays[5] = "Satur";
Wdays[6] = "Sun";
}

string dayType::setday()
{
if (day == Wdays[0])
{
i = 0;
}
else if (day == Wdays[1])
{
i = 1;
}
else if (day == Wdays[2])
{
i = 2;
}
else if (day == Wdays[3])
{
i = 3;
}
else if (day == Wdays[4])
{
i = 4;
}
else if (day == Wdays[5])
{
i = 5;
}
else if (day == Wdays[6])
i = 6;
else
{
day = "Invalid Input";
i = 7;
}
return day;
}
string dayType::preday()
{
if (i == 0)
prDay = Wdays[6];
else if (i == 7)
prDay = "Invalid Input";
else
prDay = Wdays[i - 1];
return prDay;
}
void dayType::Nextday()
{
if (i == 6)
NxtDay = Wdays[0];
else if (i == 7)
prDay = "Invalid Input";
else
NxtDay = Wdays[i + 1];

}
string dayType::add(int n)
{
n = n + i;
while (n>= 7)
{
n = n - 7;
}
if (i == 7)
Wdays[n] = "Invalid Input ";
return AddDays = Wdays[n];
}
void dayType::print()
{
cout << endl <<"\tDay="<< day <<"day"<< endl;
cout <<"\tPrevious day :"<< prDay <<"day"<< endl;
cout <<"\tNext day :"<< NxtDay <<"day"<< endl;
cout <<"\tAfter Adding Days :"<< AddDays <<"day"<< endl;
}
void menu()
{
cout <<"MENU"<< endl;
cout <<"\tEnter 'Sun' for 'Sunday'"<< endl;
cout <<"\tEnter 'Mon' for 'Monday'"<< endl;
cout <<"\tEnter 'Tues' for 'Tuesday'"<< endl;
cout <<"\tEnter 'Wednes' for 'Wednesday'"<< endl;
cout <<"\tEnter 'Thurs' for 'Thursday'"<< endl;
cout <<"\tEnter 'Fri' for 'Friday'"<< endl;
cout <<"\tEnter 'Satur' for 'Saturday'"<< endl;
}
output of this code:

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 21:40
Develop a function to create a document in the mongodb database “city” in the collection “inspections.” be sure it can handle error conditions gracefully. a. input -> argument to function will be set of key/value pairs in the data type acceptable to the mongodb driver insert api call b. return -> true if successful insert else false (require a screenshot)
Answers: 2
question
Computers and Technology, 23.06.2019 18:00
While inserting images, the picture command is usually used to insert photos from a digital camera, and the clip art command is usually used to a.edit the sizes and other characteristics of photos that have been inserted. b.take a screenshot of an image and copy it to the clipboard for pasting. c.search for drawings or other images from a library of prepared pictures. d.make illustrations using lines and shapes that are easy to manipulate.
Answers: 1
question
Computers and Technology, 23.06.2019 23:30
The keyboard usually has six rows of keys. which of the following is not one of the key group categories? letter keys number keys control keys graphic keys
Answers: 1
question
Computers and Technology, 24.06.2019 12:50
When is it most apprpriate for a development team to change the definition of done
Answers: 1
You know the right answer?
#include #include
using namespace std;

void menu();

class dayType
Questions
question
Mathematics, 18.02.2021 22:10
question
Chemistry, 18.02.2021 22:10
question
English, 18.02.2021 22:10
question
Spanish, 18.02.2021 22:10
Questions on the website: 13722361