hi i have this code to print out a calendar based on the year and month entered by user!!!!!
but im getting only the heading information ???can someone take a look at it and tell me whats wrong??TANX
my code so far is::
Full code removed per Posting Guidelines
20 5327
i need to write a program that prints the 12 months calandar given the weakday which should be the 1st of January for the years of 2001 and 2004( a leap year)!!! i know the test for leap year and i have written the FUN to determine the number of the days of months.
i just dont know how to print the calandar like
S M T W TH F SU
1 2 3 4 5 6
7 8 9 10 11 12 13
and so on....and the the of the next month should follow the end of previous month
... im sure i have to use the reference variables but im not sure how??
can you guys give me any ideas?
TANX
It should just be a matter of deciding how many days each month has, and then printing them in alignment (check out the setw() function in the iomanip header file for this). The first half is a mixture of simple logic and constants, the second half is experiment and 'making it look pretty'.
It should just be a matter of deciding how many days each month has, and then printing them in alignment (check out the setw() function in the iomanip header file for this). The first half is a mixture of simple logic and constants, the second half is experiment and 'making it look pretty'.
i know how many days esch month has. i dont know hoe to put the first day of January on the day of the week that user chooses?
like when a user inputes 2 (when Sunday is 1 and saturday is 7) the 1st day of january should be on monday!!!!!any ideas?
I think your main( ) needs changes. You need to assign the functions to variables when you are returning values from those functions. Also the code to generate the calendar needs to be appropriately changed. (Like the half written code inside the comment needs to be refined and continued...)
Again, this is a matter of experiment to make it look 'good'. My solution would be to simply print a certain number of spaces until you got under the 'M' spot, and then beginning to print.
Alenik1989-
Please do not double post - confine yourself to a single thread for each question you have.
Thanks
actually i didnt write the end of this code (my friend wrote it) where the code is
Full code removed per Posting Guidelines
can anyone please tell me whats the rule of this FUN, i mean whats is the daysofweek ? and what should i do with it?
Try stepping through the code line by line. Pass it a value that you think would make sense, and see where the logic takes you. Then pass it a value that you think would not make sense and see where the logic takes you.
As this is your friends code, I'm removing it from your post (due to our Posting Full Code rule in the Posting Guidelines, but if you come across a specific part you don't understand, post that part and your question, as well as the values you put in, what you got back, and why it doesn't make sense to you.
i just need a loop to print out the numbers from function in lines that in each line there will be 7 numbers!!!!!
like
1 2 3 4 5 6 7
8 9 10 11 12 13 14
i got the FUNC to determine the number of days ina month so -
int i=1,j=1
-
while( i<=FUNC)
-
{
-
while( j<=7)
-
{
-
if(i<=FUNC)
-
{
-
cout<<" "<<i;
-
i++
-
j++
-
}
-
else
-
break;
-
}
-
cout<<endl;
-
j=1
-
}
-
just wanna know is this loop gonna work??? if not any idea how to write it???!!
please i need ASAP!! TANX
just wanna know is this loop gonna work???
I have no idea. Did you compile it?
I have no idea. Did you compile it?
yeh i got it!!!!tanx
i rewrote the code (myself) and now my code is like -
#include<iostream>
-
#include<iomanip>
-
using namespace std;
-
//_____________________Prototypes
-
int leaptest(int);
-
int daysofmonth(int,int);
-
void printcalandar(int,int);
-
int main()
-
{
-
int year,month=1;
-
cin>>year;
-
leaptest(year);//leapyearcheck
-
while (month<=12)
-
{
-
daysofmonth(month,year);//# of days in a month
-
printcalandar (month,year);//printing the calandar
-
month++;
-
}
-
return 0;
-
}
-
int leaptest (int year)
-
{
-
if((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
-
return 1; /* leap */
-
else
-
return 0; /* no leap */
-
}
-
int daysofmonth (int month,int year)
-
{
-
int days;
-
int month2;
-
month2 = month + 11;
-
month2 = month2 * 7;
-
month2 = month2 % 12;
-
if (month2 < 7)
-
days = 31;
-
else if (month==2)
-
{
-
if(leaptest(year)==1)
-
days=29;
-
else
-
days=28;
-
}
-
else
-
days=30;
-
return days;
-
}
-
void printcalandar(int month,int year)
-
{
-
int i=1,j=1;
-
while(i<=daysofmonth(month,year))
-
{
-
while(j<=7)
-
{
-
if(i<=daysofmonth(month,year))
-
{
-
cout<<setw(4)<<i;
-
i++;
-
j++;
-
}
-
else
-
break;
-
}
-
cout<<endl;
-
if(i<=daysofmonth(month,year))
-
j=1;
-
else
-
break;
-
}
-
cout<<"I="<<i<<" j="<<j<<endl;
-
}
this code will print 12 group month's calandar right.
but i want it to be like ...when each month ends the next month starts on the dayof the week that follows the last day of the preceding month!!!
like when january 31 is Monday then February 1st has to be on Thuesday.
Any ideas how??
i need it today pleasssssssssseeee!!!!
TANX
I'd create a variable, say 'dayOfWeekYesterday' and store it in there.
I'd create a variable, say 'dayOfWeekYesterday' and store it in there.
im new to programming, so can you be a little more specific?please?
where do i put the variable and how i make the loop to see it?
im new to programming, so can you be a little more specific?please?
where do i put the variable and how i make the loop to see it?
I would read up on rules of scope to decide where you should put that variable, but I'd recommend: your program. If you declare it outside your loop, your loop can see it. If you declare it inside your loop, your loop can see it, but every time the loop starts over, it will have an undefined value that you will need to reset.
I would read up on rules of scope to decide where you should put that variable, but I'd recommend: your program. If you declare it outside your loop, your loop can see it. If you declare it inside your loop, your loop can see it, but every time the loop starts over, it will have an undefined value that you will need to reset.
SORRY, but i still dont get it?
what is that variable suppose to do?
please i just have this pronblem with my calandar!!!
(i feel so stupid right now!!!!)
SORRY, but i still dont get it?
what is that variable suppose to do?
please i just have this pronblem with my calandar!!!
(i feel so stupid right now!!!!)
The variable holds the day of the week that the month ended with (as this is what you asked just a few posts ago...). Then you initialize the new month with the day after the one held in the variable.
The variable holds the day of the week that the month ended with (as this is what you asked just a few posts ago...). Then you initialize the new month with the day after the one held in the variable.
okay i knew that part but in order to give the variable the day of the week that the month ended with i have to put it the void printcalandar(month,year) function and before the final break right?
so after the function ends the memory location of all variables including this one will dialocated right?
so how a im suppose to initialize the new month with the day after the on in the variobale? (i know i have to add i to that variable but it should be in the functon as well)
okay i knew that part but in order to give the variable the day of the week that the month ended with i have to put it the void printcalandar(month,year) function and before the final break right?
so after the function ends the memory location of all variables including this one will dialocated right?
so how a im suppose to initialize the new month with the day after the on in the variobale? (i know i have to add i to that variable but it should be in the functon as well)
So printcalendar() only prints a month?
As it is declared a void, you aren't currently returning anything. You could return the current day of week, and then pass it back to that function.
So printcalendar() only prints a month?
As it is declared a void, you aren't currently returning anything. You could return the current day of week, and then pass it back to that function.
yeh printcalandar is a void function that i have putted in a while loop in main function to just print the 12 months using the # days in month. -
while (month<=12)
-
{
-
daysofmonth(month,year);
-
printcalandar (month,year);
-
month++;
-
}
but i cant return a value in void function can i?
you mean i have to change it to a returning value function?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Mario |
last post by:
Hello all, I'm trying hard to make possible to print some simple text from
python to the default printer using wxPython, after days of internet
searches I found this page:...
|
by: Nigel |
last post by:
I successfully create a .NET Component (Visual Basic .NET) that would
print, unfortunately when used within a web browser it appears that .NET
security doesn't allow you to run code that interacts...
|
by: Parthiv Joshi |
last post by:
I want to make a week view calendar control just as month view
calendar control given in .NET...Do anyone know how to make it..and if
anybody has the source code..kindly post it...I want to learn...
|
by: TristaSD |
last post by:
Hi,
Here's a link to a simple php-based system I'm working on. Go ahead
and play nice, nothing is validated :)
http://www.basementflooded.com/reserv
Currently, a calendar date is...
|
by: Kevin |
last post by:
In my VB2005 Windows Forms program I want to be able to click a button
and have my Dot Matrix printer print one 15/16 x 3 1/2 address label
from continuous forms.
I'm trying to use a...
|
by: hugo |
last post by:
I need urgent help with this program:
Using C, write a calendar progam so that the user provides only a year. The program should print a calendar for the given year to the file calendar.dat. The...
|
by: Marc |
last post by:
Hi,
I am setting up a orint function that prints the screen area. It is all
working except my screen area spans two print pages hwne viewed using a
print preview dialogue . I am trying to fnd a...
|
by: markclinn |
last post by:
I am trying to use the calander control to pick a date and retrieve information from a database. When a date is clicked on, the page re-loads, with the selected date, gets the informatino from the...
|
by: rafiki31 |
last post by:
I have been hitting walls trying to find the right way to print from a web application. Here is the thing, im implementing a webapplication for a kiosk. The kiosk has its own card printer. When i...
|
by: William (Tamarside) |
last post by:
Please, if you have the time and knowledge to help me I'd truly
appreciate it!
I need to build a calendar page that displays available/unavailable
info from a DB and colour a cell according to...
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
| |