I am currently taking C++, and I just want to know why it says,"Illegal Else without if," and I would like to know how to fix it so I will not encounter this problem again. I would like to know where to put the brackets, "{ "
Here is the Code:
<snipped>
//CS 1361, Spring 2008
//Lab 21
#include "stdafx.h"
#include <fstream>
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
const string ID = "<snipped> - CS 1361, Spring 2008 - Lab 21";
int main()
{
int x,
y,
z,
u,
v,
w,
t,
d,
c,
year;
ifstream fin;
ofstream fout;
cout << "running Lab 01 . . . " << endl << endl;
fin.open("lab21.dat");
fout.open("<snipped> - CS 1361, Spring 2008 - Lab 21.out");
if (!fin) //p. 175 Testing the State of an I/O stream
{
cout<<"Can't open the input file." << endl << endl;
return 1;
}
fin >> year;
// Calculate
x = ((year) / (100 + 1));
y = ((3 * x) / (4 - 12));
z = ((year % 19) + 1);
u = (((8 * x) + 5) / ((25 -5) - y));
v = ((5 * year) / ((4 - y) - 10));
w = ((11 * z) + (20 + u));
t = (w % 30);
fout << ID << endl;
if (t == 25)
{
if (z > 11)
else
t = (t + 1);
}
if (t == 24)
else
t = (t + 1)
d = (44 - t)
if (d < 21)
else
d = (d + 30)
c = (d + v);
d = ((d + 7) - (c % 7));
if (d > 31)
d = (d - 31));
fout << d << endl;
else
fout << d << endl;
fout << year << endl;
return 0;
}