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 10:00
You need a reliable network for about twenty-five computers that will be distributed across a large building. it is important that the network be relatively cheap. which topology should you use?
Answers: 1
question
Computers and Technology, 22.06.2019 19:30
Once the data center routes to the destination server that hosts the website, what's the next step in the internet process? user’s browser renders html code from destination server into web page request goes through router/model and isp request routed to nameserver and datacenter
Answers: 2
question
Computers and Technology, 23.06.2019 01:20
Me with this program in c++ ! computers represent color by combining sub-colors red, green, and blue (rgb). each sub-color's value can range from 0 to 255. thus (255, 0, 0) is bright red. (130, 0, 130) is a medium purple. (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded purple, due to the (50, 50, 50) gray part. (in other word, equal amounts of red, green, blue yield gray).given values for red, green, and blue, remove the gray part. ex: if the input is 130 50 130, the output is: 80 0 80. thus, find the smallest value, and then subtract it from all three values, thus removing the gray.
Answers: 3
question
Computers and Technology, 23.06.2019 04:10
2pointswho was mikhail gorbachev? oa. a russian leader who opposed a coupob. a polish leader who founded the labor union "solidarityoc. a soviet leader who called for a closer relationship with the unitedstates, economic reform, and a more open societyd. a soviet leader who called for more oppression in the soviet union
Answers: 3
You know the right answer?
#include #include
using namespace std;

void menu();

class dayType
Questions
question
English, 22.05.2021 21:40
question
Mathematics, 22.05.2021 21:50
question
Mathematics, 22.05.2021 21:50
Questions on the website: 13722360