Calculating a future day

Hey guys I need some help with my code to calculate a future day. Everything seems to be almost there, but I need the future day to pop up.

Here's my code,

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

int main() {
//declare vars
string Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday;
string day;
string futureDay;
string number;
int days;
int remainder = 0;
int dayNumber;

// input
cout << "Please enter the current day and a number: " << endl;
cin >> day >> number;

// compute
if (day == "Monday") {
dayNumber = 1;
}
else if (day == "Tuesday") {
dayNumber = 2;
}
else if (day == "Wednesday") {
dayNumber = 3;
}
else if (day == "Thursday") {
dayNumber = 4;
}
else if (day == "Friday") {
dayNumber = 5;
}
else if (day == "Saturday") {
dayNumber = 6;
}
else if (day == "Sunday") {
dayNumber = 7;
}
remainder = (days + dayNumber) % 7;

// compute the futureDay
if (futureDay = 1) {

}

// output
cout << "The future days is: " << futureDay;

// pause and exit
getchar();
getchar();
return 0;
}
Last edited on
Does the function getchar() exist? I think the function should be getch().
Does the function getchar() exist?

Yes, although the OP should #include <cstdio>

I think the function should be getch().

No.

To the OP: futureDay is never assigned any value. It is an empty string. If you want it to be set to something, set it to something.
Last edited on
Do you mind explaining it more to me? I've been having a hard time with CS. Also, our teacher has been working <iostream> with us and we've never learned <cstdio>.
Do you mind explaining it more to me?

I'm not sure what you want explained. If you never assign a string a value, it will remain empty. You never assign the string futureDay a value, so it remains empty. As well, you have a bunch of other variables that are never used. What are they (Sun, Mon, etc.) there for?


I've been having a hard time with CS. Also, our teacher has been working <iostream> with us and we've never learned <cstdio>.

Then you probably should be using C input functions like getchar. The C++ equivalent to getchar(); is cin.get();, but if your environment is configured correctly neither should be necessary.

Last edited on
Topic archived. No new replies allowed.