473,395 Members | 1,869 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

I need to return m,d,y back to the main -

public class Date
{
public Date(int m, int d, int y)
{
day = nextDay(m,d,y);
if(day == 1)
month = nextMonth(m,d);
if (m == 1 && d == 1)
y = nextYear(y);
System.out.println(" " + m + "/"+ d+"/"+y):
}
public static int nextDay(int m, int d, int y)
{
switch(d){
case 28:
if(y%4 == 0)
++d;
else
if(m == 2)
d = 1;
break;
case 29:
if(m == 2)
d = 1;
break;
case 31: d = 1; break;
default: ++d; break;
}
return day;
}
public static int nextMonth(int m, int d)
{
if( m == 12 & d == 1)
m = 1;
else
if (d == 1)
++m;
return m;
}
public static int nextYear(int y)
{
return ++y;
}
}
===========================
public class DateTest
{
public static void main(String[] args)
{ int m,d,y;
m = 2;d=28;y = 2011;
System.out.println(" " + m + "/"+ d+"/"+y);// this line should give 2/28/2011
new Date(m,d,y);
System.out.println(" " + m + "/"+ d+"/"+y);// this line should give 3/1/2011
Date.nextDay(m, d, y); System.out.println(" " + m + "/"+ d+"/"+y);//
this line should give 3/2/2011

}
}
Mar 18 '11 #1
0 932

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: lawrence | last post by:
I've been bad about documentation so far but I'm going to try to be better. I've mostly worked alone so I'm the only one, so far, who's suffered from my bad habits. But I'd like other programmers...
1
by: Piotr | last post by:
I have popup window (window.open) where I put any value in input field. After submit I wan to to return to the main window and get value from popup window. How to close popup window and return to...
25
by: KK | last post by:
Hi, I am using history.go(-1) for implementing the back button functionality. Its working fine but with this exception. 1. The page which is having back button has some hyperlinks on it. ...
7
by: ballpointpenthief | last post by:
Hello, I'm thinking that it would be a good idea to start using the return code for main() to return the amount of memory still allocated (which would hopefully be zero) to ensure all memory has...
7
by: Jaggu | last post by:
Hi , I need to close main window, once the child window succesfully opens else main window to remain. In my case when I close the main window immediately after the "window.open()" as mentioned...
3
by: Synapse | last post by:
Hello people...i need help in my code. I have a confirm dialog below and it will ask you to repeat the program again. now my problem is that if i choose yes, it will exit the application. here's my...
11
by: eros | last post by:
I use md5 function of PHP before storing the password in the database. Scenario: I put an password retrieval program. After authentication that the username is realy exist, send an email...
3
by: Pietro Cerutti | last post by:
Hi group, please tell me if this rather belongs to comp.unix.programmer or such.. I would like to know whether there is a portable way to return a integer type not limited to 0xff from main. In...
5
by: WanHongbin | last post by:
#include <stdio.h> double square(); /*without declare main() { double s; s = square(2); printf("%g\n", s); }
2
by: Selva123 | last post by:
Hi All, Greetings. May be simple issue but your help sought. I am executing the system command like $res=system("notepad.exe"); thro a perl file named aa.pl. At command prompt - when I enter ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.