Hi guys, I'm trying to run this program that asks the user to select 1 - 7 from a menu then output it in a printData() function member from my class DaysofTheWeek.
I can get the porgram to compile with no errors but my output is not what i want or expect. I'm still new and don't fully understand the grammer of CLASSES and how to fully use them.
Any help would be awesome!
#include"stdafx.h"
#include<iostream>
#include<string>
usingnamespace std;
class DayofTheWeek
{
string day;
int selection;
public:
void setdata(string, int);
string getdata();
void printdata();
};
int main()
{
// int selection
DayofTheWeek today;
// today.setdata;
today.printdata();
system("pause");
return 0;
}
void DayofTheWeek::setdata(string temp, int temp2)
{
day = temp;
selection = temp2;
cout << "Select todays' day: " << 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;
cout << "7: Sunday" << endl;
switch(temp2)
{
case 1:
cout << "Yesterday was Sunday, Tomorrow will be Tuesday, and today is Monday." << endl;
break;
case 2:
cout << "Yesterday was Monday, Tomorrow will be Wednesday, and today is Tuesday." << endl;
break;
case 3:
cout << "Yesterday was Tuesday, Tomorrow will be Thursday, and today is Wednesday." << endl;
break;
case 4:
cout << "Yesterday was Wednesday, Tomorrow will be Friday, and today is Thursday." << endl;
break;
case 5:
cout << "Yesterday was Thursday, Tomorrow will be Saturday, and today is Friday." << endl;
break;
case 6:
cout << "Yesterday was Friday, Tomorrow will be Sunday, and today is Saturday." << endl;
break;
case 7:
cout << "Yesterday was Saturday, Tomorrow will be Monday, and today is Sunday." << endl;
Question
saiya
Hi guys, I'm trying to run this program that asks the user to select 1 - 7 from a menu then output it in a printData() function member from my class DaysofTheWeek.
I can get the porgram to compile with no errors but my output is not what i want or expect. I'm still new and don't fully understand the grammer of CLASSES and how to fully use them.
Any help would be awesome!
Link to comment
Share on other sites
10 answers to this question
Recommended Posts