cout<<"Five Days from today will be: ";
dayOne.addDays("Wedsnday", 5);
doesn't show. I don't know what went wrong. Can anyone figure out where I went wrong?
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace System;
using namespace std;
class DaysOfTheWeek
{
private:
string day;
string mon;
string tue;
string wed;
string thur;
string fri;
string sat;
string sun;
public:
//constructors
DaysOfTheWeek();
DaysOfTheWeek(string);
//Functions
void setDay (string);
void printDay (void);
string getDay (void);
void nextDay (string);
void previousDay (string);
void plusOneDay (int);
void minusOneDay (int);
void addDays (string, int);
};
int main()
{
cout<<"Days of the week"<<endl;
//Displays for Day 1
cout<<"** Day 1 **"<<endl;
DaysOfTheWeek dayOne;
dayOne.setDay("Wedsnday");
dayOne.getDay();
cout<<"Today is :";
dayOne.printDay();
cout<<"Yesterday was: ";
dayOne.previousDay("Wedsnday");
cout<<"Tomorrow will be: ";
dayOne.nextDay("Wedsnday");
cout<<"Five Days from today will be: ";
dayOne.addDays("Wedsnday", 5);
cout<<endl;
//Displays for Day 2
cout<<"** Day 2 **"<<endl;
DaysOfTheWeek dayTwo("Sunday");
dayTwo.setDay("Sunday");
dayTwo.getDay();
cout<<"Today is :";
dayTwo.printDay();
cout<<"Yesterday was: ";
dayTwo.previousDay("Sunday");
cout<<"Tomorrow will be: ";
dayTwo.nextDay("Sunday");
cout<<"Two Days from today will be: ";
dayTwo.addDays("Sunday", 2);
cout<<endl;
return 0;
}
DaysOfTheWeek::DaysOfTheWeek()
{
day = " ";
}
DaysOfTheWeek::DaysOfTheWeek(string myDays)
{
mon = "Monday";
tue = "Tuesday";
wed = "Wedsnday";
thur = "Thursday";
fri = "Friday";
sat = "Saturday";
sun = "Sunday";
}
void DaysOfTheWeek::setDay(string d)
{
day = d;
}
string DaysOfTheWeek::getDay(void)
{
return day;
}
void DaysOfTheWeek::printDay(void)
{
cout<< day <<endl;
}
void DaysOfTheWeek::nextDay(string dayN)
{
string nextDay = " ";
//Enter loop to determine the following day
if (dayN == "Monday")
{cout<< "Tuesday" <<endl;}
if (dayN == "Tuesday")
{cout<< "Wedsnday" <<endl;}
if (dayN == "Wedsnday")
{cout<< "Thursday" <<endl;}
if (dayN == "Thursday")
{cout<< "Friday" <<endl;}
if (dayN == "Friday")
{cout<< "Saturday" <<endl;}
if (dayN == "Saturday")
{cout<< "Sunday" <<endl;}
if (dayN == "Sunday")
{cout<< "Monday" <<endl;}
}
void DaysOfTheWeek::previousDay(string dayP)
{
string prevDay = " ";
//entering loop for the past day
if (dayP == "Monday")
{cout<< "Sunday" <<endl;}
if (dayP == "Tuesday")
{cout<< "Monday" <<endl;}
if (dayP == "Wedsnday")
{cout<< "Tuesday" <<endl;}
if (dayP == "Thursday")
{cout<< "Wedsnday" <<endl;}
if (dayP == "Friday")
{cout<< "Thursday" <<endl;}
if (dayP == "Saturday")
{cout<< "Friday" <<endl;}
if (dayP == "Sunday")
{cout<< "Saturday" <<endl;}
}
void DaysOfTheWeek::plusOneDay(int add)
{
//declared variables
int added= 0;
//calculations
for (int a = 0; a < 7; a++){
if (added < add)
{added = added + 1;}
//Displays
cout<<added<<endl;
}
}
void DaysOfTheWeek::minusOneDay(int sub)
{
//declared variables
int subt = 0;
//calculations
for (int b = 0; b > 7; b = b - 1){
if (subt > sub)
{subt = subt - 1;}
//Displays
cout<<subt<<endl;
}
}
void DaysOfTheWeek::addDays(string current, int count)
{
//Comparisons
day = count;
//entering loop
if (current == "Monday"){
if (count == 1)
{cout<<tue<<endl;}
if (count == 2)
{cout<<wed<<endl;}
if (count == 3)
{cout<<thur<<endl;}
if (count == 4)
{cout<<fri <<endl;}
if (count == 5)
{cout<<sat <<endl;}
if (count == 6)
{cout<<sun<<endl;}
if (count == 7)
{cout<<mon <<endl;} }
if (current == "Tuesday"){
if (count == 1)
{cout<<wed<<endl;}
if (count == 2)
{cout<<thur<<endl;}
if (count == 3)
{cout<<fri<<endl;}
if (count == 4)
{cout<<sat <<endl;}
if (count == 5)
{cout<<sun <<endl;}
if (count == 6)
{cout<<mon<<endl;}
if (count == 7)
{cout<<tue <<endl;} }
if (current == "Wedsnday"){
if (count == 1)
{cout<<thur<<endl;}
if (count == 2)
{cout<<fri<<endl;}
if (count == 3)
{cout<<sat<<endl;}
if (count == 4)
{cout<<sun <<endl;}
if (count == 5)
{cout<<mon<<endl;}
if (count == 6)
{cout<<tue<<endl;}
if (count == 7)
{cout<<wed <<endl;} }
if (current == "Thursday"){
if (count == 1)
{cout<<fri<<endl;}
if (count == 2)
{cout<<sat<<endl;}
if (count == 3)
{cout<<sun<<endl;}
if (count == 4)
{cout<<mon <<endl;}
if (count == 5)
{cout<<tue <<endl;}
if (count == 6)
{cout<<wed<<endl;}
if (count == 7)
{cout<<thur <<endl;} }
if (current == "Friday"){
if (count == 1)
{cout<<sat<<endl;}
if (count == 2)
{cout<<sun<<endl;}
if (count == 3)
{cout<<mon<<endl;}
if (count == 4)
{cout<<tue <<endl;}
if (count == 5)
{cout<<wed <<endl;}
if (count == 6)
{cout<<thur<<endl;}
if (count == 7)
{cout<<fri <<endl;} }
if (current == "Saturday"){
if (count == 1)
{cout<<sun<<endl;}
if (count == 2)
{cout<<mon<<endl;}
if (count == 3)
{cout<<tue<<endl;}
if (count == 4)
{cout<<wed <<endl;}
if (count == 5)
{cout<<thur <<endl;}
if (count == 6)
{cout<<fri<<endl;}
if (count == 7)
{cout<<sat <<endl;} }
if (current == "Sunday"){
if (count == 1)
{cout<<mon<<endl;}
if (count == 2)
{cout<<tue<<endl;}
if (count == 3)
{cout<<wed<<endl;}
if (count == 4)
{cout<<thur <<endl;}
if (count == 5)
{cout<<fri <<endl;}
if (count == 6)
{cout<<sat<<endl;}
if (count == 7)
{cout<<sun <<endl;} }
}

New Topic/Question
Reply




MultiQuote







|