Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 04-26-2001, 04:38 PM   #1
MITotaku
Guest
 
Posts: n/a
splat

Okay, this has been bugging me for a while.

I'm writing this code to display a calendar. And of course there is something wrong. I can't even test it, because when it compiles I receive the error message: "End of file found." Anyway... here is the code. I hope pre tags work on this post.


//Brad Weir
//Calendar.CPP
//Calendar Program

/*

Calendar Reference Table

Month | #Days | Base Yr. | Day Start
------------------------------------
Jan 31 2000 Sunday
Feb 28-29 2000 Wednesday
Mar 31 2000 Wednesday
Apr 30 2000 Saturday
May 31 2000 Monday
Jun 30 2000 Thursday
Jul 31 2000 Saturday
Aug 31 2000 Tuesday
Sep 30 2000 Friday
Oct 31 2000 Sunday
Nov 30 2000 Wednesday
Dec 31 2000 Friday

*/

#include

main()
{
//local variables
char end[4];
int invalid, a, i;
int year, month, leap;
char calarr[42];

//inside program
while ((end != "Y") || (end != "Yes"))
{
invalid = 1; //makes the continue check run

cout << "\nWELCOME TO THE CALENDAR GENERATOR v1.0";
//prompt for year
cout << "\nEnter the year:";
cin >> year;
//prompt for month
cout << "Enter the month as a number...\n1.January\n2.February\n3.March\n4.April\n5.May\n6.June\n7.July\n8.August\n9.September\n10 .October\n11November\n12.December\n";
cin >> month;

leap = 0;

leapmod = year%4;
if (leapmod == 0)
{
leap = 1;
}

int days, start, valadd, i, stoval;

//find the number of days
if (month == 1)
{
days = 31;
start = 1;
}
if (month == 2)
{
if (leap == 1) //incase of leap year
{
days = 29;
start = 4;
}
else
{
days = 28;
start = 4;
}
}
if (month == 3)
{
days = 31;
start = 4;
}
if (month == 4)
{
days = 30;
start = 7;
}
if (month == 5)
{
days = 31;
start = 2;
}
if (month == 6)
{
days = 30;
start = 5;
}
if (month == 7)
{
days = 31;
start = 7;
}
if (month == 8)
{
days = 31;
start = 3;
}
if (month == 9)
{
days = 30;
start = 6;
}
if (month == 10)
{
days = 31;
start = 1;
}
if (month == 11)
{
days = 30;
start = 4;
}
if (month == 12)
{
days = 31;
start = 6;
}

//find new starting day of week
valadd = year - 2000; //find value to add to start
start = start + valadd; //add value to start

if (start > 7)
{
i = int(year/7);
start = start - 7 * i;
}
if (start < 1)
{
start = start * (-1);
{

for (i=0; i<start-1; i++)
{
calarr[i] = char(" ");
}

for (i=start-1; i<days; i++)
{
stoval = i - start - 2;
calarr[i] = char(stoval);
}

for (i=days-1; i<42; i++)
{
calarr[i] = char(" ");
}

//display calendar
cout << "\n" << month << "-" << year;
cout << "\n______________________";
cout << "\n|Su|Mo|Tu|We|Th|Fr|Sa|";

i = 0;

for (a=1; a<=6; a++)
{
cout << "\n|";
for (i=i; i<7*a; i++)
{
cout << calarr[i];
if (int(calarr[i]) < 10)
{
cout << " ";
}
cout << '|';
}
}

//continue check
while (invalid == 1)
{
cout << "\nWould you like to continue?(Enter:Y/Yes/N/No)";
cin >> end;
if ((end != "Y") && (end != "Yes") && (end != "N") && (end != "No"))
{
cout << "\nINVALID RESPONSE: Enter only Y, Yes, N or No";
invalid = 1;
}
else
{
invalid = 0;
}
}
}
return 0;
}


...hopefully that turns out right.

I was using functions, but I thought that's what was causing the problem, so I took them out. I don't think it has anything to do with missing brackets or semi-colons. What is the reason I'm getting this problem?
  Reply With Quote
Old 04-26-2001, 04:53 PM   #2
MITotaku
Guest
 
Posts: n/a
forgot the &lt, &gt on the include

oops!

at the top for the #include statement it should read:

 #include <iostream.h> 


I forgot the lt's and gt's there.
  Reply With Quote
Old 04-26-2001, 06:39 PM   #3
Member (12 bit)
 
Paul Victorey's Avatar
 
Join Date: Mar 1999
Location: MN or WI
Posts: 3,017
Well, if that was copied and pasted, you have a bracket mismatch in there:

if (start < 1)
{
start = start * (-1);
{

Instead of

if (start < 1)
{
start = start * (-1);
}


__________________
Paul M. Victorey
------------------
I am not responsible for any problems that may arise as a result of following my advice. This includes, but is not limited to, computer failure, loss of data, nuclear war, famine, boils, no clean laundry, your daughter running off with a biker gang, or armageddon. Take my advice at your own risk.
Paul Victorey is offline   Reply With Quote
Old 04-28-2001, 09:00 PM   #4
MITotaku
Guest
 
Posts: n/a
Talking GOT IT TO WORK!!

Well I got the thing to work thanks for your help. A+ and extracredit. I love school.
  Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 07:14 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2