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 17:50
Farah works in an office with two other employees. all three share a printer and an internet connection. the utility that makes this possible is defragger quicktime soho winzip
Answers: 1
question
Computers and Technology, 22.06.2019 18:30
The "instance" relationship shows that something is an object of a
Answers: 1
question
Computers and Technology, 22.06.2019 22:00
Discuss the ways in which electronic information associated with payments is addressed in terms of security. include encryption, secure sockets layers, and secure electronic transactions in your discussion. are there any other ways that consumers and businesses can keep their payment information secure in an electronic commerce environment? do you feel that your information is safe when conducting electronic business? why or why not?
Answers: 1
question
Computers and Technology, 23.06.2019 04:31
Selling a product through an electronic medium is
Answers: 1
You know the right answer?
#include #include
using namespace std;

void menu();

class dayType
Questions
question
Mathematics, 07.06.2021 16:20
question
Mathematics, 07.06.2021 16:20
question
Mathematics, 07.06.2021 16:20
question
Computers and Technology, 07.06.2021 16:20
question
Mathematics, 07.06.2021 16:20
Questions on the website: 13722360