#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
using namespace std;
//function prototypes
void DetermineWeekDay(int, int, int, int, int, int, int, int&);
int main()
{
int JDN;
int day;
int month;
int year;
int DayofWeek;
int intRes1;
int intRes2;
int intRes3;
bool dataareOK = false;
do
{
cout << "Please input the date month, day, year seprated by a space: ";
cin >> month >> day >> year;
if (month < 13)
dataareOK = true;
else
cout << "Please enter a number smaller than 13 for the month: "
<< endl;
if ( day<32);
else
cout << "Please enter a number smaller than 32 for the day:"
<< endl;
} while (dataareOK == false);
DetermineWeekDay (day, month, JDN, year, intRes1, intRes2, intRes3, DayofWeek);
cin.get(), cin.get();
return 0;
}
void DetermineWeekDay(int day, int month, int JDN, int year, int intRes1,
int intRes2, int intRes3, int& DayofWeek )
{
//Precondition: day of week must be entered
//Postcondition: user enters correct information
// Reference parameter DayofWeek calculated
JDN = ((intRes1 + intRes2 + intRes3 + day) + 1720944.5);
DayofWeek = ((JDN + 1) % 7);
intRes1 = (2- year /100 + year / 400);
intRes2 = int(365.25 * year);
intRes3 = int(30.6001 * (month + 1));
cout << " The day of the week " << " for "
<< month << day << year << "is" << DayofWeek;
if (DayofWeek == 0)
cout << "Sunday";
else if (DayofWeek == 1) //Nested If
cout << "Monday";
else if (DayofWeek == 2) //Nested If
cout << "Tuesday";
else if (DayofWeek == 3) //Nested If
cout << "Wednesday";
else if (DayofWeek == 4) //Nested If
cout << "Thursday";
else if (DayofWeek == 5) //Nested If
cout << "Friday";
else if (DayofWeek == 6) //Nested If
cout << "Saturday";
cout << endl;
return;
}
here are the run time errors
Symbols loaded.
No symbols loaded.
No symbols loaded.
Failure #3 - The variable 'intRes3' is being used without being defined.
Run-Time Check Failure #3 - The variable 'intRes2' is being used without being defined.
Run-Time Check Failure #3 - The variable 'intRes1' is being used without being defined.
Run-Time Check Failure #3 - The variable 'JDN' is being used without being defined.
The thread 'Win32 Thread' (0xdb8) has exited with code -1073741510 (0xc000013a).
The program '[3456] : Native' has exited with code -1073741510 (0xc000013a).
I also have a goof in the math as far as if the date is later than 10 15 1582 then I compute w/ the intRes1 formula otherwise intRes1 will be zero.. here is what I tried to insert but I got many errors.. how would I write that in.. here is what I did
if (month >> day >> year > 10 15 1582) intRes1 = (2- year /100 + year / 400); else intRes1 = 0

New Topic/Question
Reply


MultiQuote




|