I have this program that will ask user to put in the day, it compiles but every time i set the day to Saturday this program won't display Saturday, instead it shows Sunday. It also won't correctly generate the output for yesterday if the current day is Sunday and tomorrow if the current day is Saturday,

Lastly this program have function that will display the day specified by user after the current day
say today is Tuesday and i put 2 for the next day, it will display Thursday. This function seems to work fine except when I put 6

any help would be appreciated
thank you

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

class dayType
{
  string days [6];
  string currentday;
  int daynum;
public:
  dayType()
  {
    days[0]="Sunday";
    days[1]="Monday";
    days[2]="Tuesday";
    days[3]="Wednesday";
    days[4]="Thursday";
    days[5]="Friday";
    days[6]="Saturday";
    currentday=days[0];
 daynum=0;
  }
  void setday(int);
  void printday()const;
  string returnday()const;
  string returntomorrow()const;
  string returnyesterday()const;
  void daycalculator(int)const;
};

int main()
{
  dayType myDay;
  int currentday;
  int dayadded;
  string today;
  string tomorrow;
  string yesterday;

  cout << "Please enter today's day:" << endl;
  cout << "0.Sunday" << endl;
  cout << "1.Monday" << endl;
  cout << "2.Tuesday" << endl;
  cout << "3.Wednesday" << endl;
  cout << "4.Thursday" << endl;
  cout << "5.Friday" << endl;
  cout << "6.Saturday" << endl;
cin >> currentday;
  myDay.setday(currentday);
  cout << "Enter the number of day that will be added to current day" << endl;
  cin >> dayadded;
  myDay.printday();
  today=myDay.returnday();
  tomorrow=myDay.returntomorrow();
  yesterday=myDay.returnyesterday();
  cout << "Today is "<< today << endl;
  cout << "Tomorrow is " << tomorrow << endl;
  cout << "Yesterday was " << yesterday << endl;
  myDay.daycalculator(dayadded);
}

void dayType::setday(int day)
{
  currentday=days[day];
  daynum=day;
}

void dayType::printday() const
{
  cout << "Today is " << currentday << endl;
}
string dayType::returnday() const
{
  return currentday;
}

string dayType::returntomorrow() const
{
  if((daynum+1)>6)
    return days[0];
  else
    return days[daynum+1];
}

string dayType::returnyesterday() const
{
  if((daynum-1)<0)
    return days[6];
  else
    return days[daynum-1];
}

void dayType::daycalculator(int dayadded) const
{
  int newday;

  newday=daynum+dayadded;
  if (newday>6)
    {
      newday=(newday%6)-1;
    }
  cout << "Today is " << days[daynum] << endl;
  cout << dayadded << " day(s) after today will be " << days[newday] << endl;
}

you declare your array as [6] (six elements) but you try to use 7 (0-6). Change your string days to 7

Secondly. If the day calculator function works.

You can use the same thing to return yesterday and tommorow by using daycalculator with the inputs of (1 and ,-1) right

ahhh silly mistake, i kept thinking that array[6]=0-6 hahaha

This question has already been answered. Start a new discussion instead.