CODE
#include <string>
#include <cmath>
#include <iostream>
#include <iomanip>
using namespace std;
//Determine Function Prototypes
void DetermineWeekDay(float, float, float, int, int, int, int, int&);
int main()
{
//Input variables
float day;
float month;
float year;
int DayofWeek;
long int intRes1 = 0;
long int intRes2 = 0;
long int intRes3 = 0;
long int JDN = 0;
bool dataOK = false;
do
{
cout << "Please enter the month";
cin >> month;
cout << "Please enter the week day:";
cin >> day;
cout << "Please enter the year:";
cin >> year;
if (month <= 10 && day <= 15 && year <= 1582) {
intRes1 = 0;
}
else {
cout << "year / 100 = " << year / 100
<< ", year / 400 = " << year / 400
<< endl;
intRes1 = 2 - (year / 100) + (year / 400);
}
cout << "intRes1 = " << intRes1 << endl;
{
//DoCalculation
}
} while (dataOK== false);
DetermineWeekDay (day, month, JDN, year, intRes1, intRes2, intRes3, DayofWeek);
cin.get(), cin.get();
return 0;
}
void DetermineWeekDay (float day,float month,float year,long int JDN, long int intRes1,
long int intRes2,long int intRes3,int& DayofWeek)
{
//Precondition: The day of the week must be entered.
//Postcondition: The user must enter information correctly.
intRes1 = (2-year / 100 + year / 400);
intRes2 = int(365.25 * year);
intRes3 = int(30.6001 * (month + 1));
JDN = ((intRes1 + intRes2 + intRes3 + day) + 1720944.5);
temp = intRes1 + intRes2 + intRes3 + day + 1720994.5;
if (temp - JDN>= .5)
DayofWeek = ((JDN + 1) % 7)+1;
cout << " The day of the week " << " for "
<< month << day << year << "is" << DayofWeek;
if (DayofWeek == 0)
cout << "Sunday";
else if (DayofWeek == 1)
cout << "Monday";
else if (DayofWeek == 2)
cout << "Tuesday";
else if (DayofWeek == 3)
cout << "Wednesday";
else if (DayofWeek == 4)
cout << "Thursday";
else if (DayofWeek == 5)
cout << "Friday";
else if (DayofWeek == 6)
cout << "Saturday";
cout << endl;
return;
Here are my errors and I don't know what to fix. The problem you gave me is the same one so it looks like someone else is having problems with it too.
warning C4244: '=' : conversion from 'float' to 'long', possible loss of data line 43
warning C4244: 'argument' : conversion from 'float' to 'int', possible loss of data line 56
warning C4244: 'argument' : conversion from 'long' to 'float', possible loss of data line 56
warning C4244: '=' : conversion from 'float' to 'long', possible loss of data line 69
warning C4244: '=' : conversion from 'double' to 'long', possible loss of data line 72
): error C2065: 'temp' : undeclared identifier line 73
error C3861: 'temp': identifier not found, even with argument-dependent lookup line 74