Finding the number of days in a given year
Ok, so i need to figure this one out, been at it for a few days now, but not having much luck with it.
Ok, so i have:
public class Project3 {
public static void main(String [] args) {
String enteryear = JOptionPane.showInputDialog(null, "Enter a year");
int yearnum = Integer.parseInt(enteryear);
so, what i need to do is display an output saying :
"The year" + enteryear + " has " + days + " in it"
my problem is that i can not use if then or any other advanced statements, only simple math
I am having some problems figuring out how to do this.
I have to keep in mind leap years and follow the rules for finding out if a year is a leap year:
Div by 4? leap year
Div by 100? Not a leap year
Div by 400? Leap year
but from here, im lost as to how to fit the mnath formula needed.
There are 365 days in a year. To be exact, there are
365.25 days in a year.Approximately.
Time drifts according to our precetion of importance.
What I mean, is that there is no such thing as a leap
anything. We created it (time) to suit our needs -
and is not very acuurate on the overall picture.Er, no. One revolution around the sun is not an integer number of rotations of the earth on its axis. That remainder is the physical basis for leap years and leap seconds.
Adding time would have extended our current day to be
well over 1,000,000 hours long since 'time' started.WTF are you talking about? Can I have some of whatever you're smoking?
Even trying to use to for the most scientifically
demanding task of placing objects in space at a
certain time would not be off by not figuring in time
drift since any time gained would eventually be lost
again - which is an enigma since time's speed is
constant, and we invented time to begin with.Seriously dude, you want some Doritos?
Similar Messages
-
How to get the number of days between 2 given dates
Hi all,
How can I find the number of days between any 2 given dates.
ThanksHi
Here's a dirty way:
If you've got two Date objects in Java, call getTime() on each one (which gives you a value in milliseconds), then subtract the two millisecond values, and divide the result by the number of milliseconds in a day (24 * 60 * 60 * 1000). There's more `elegant' ways to do this, but this method only requires one line of Java.
Best wishes
Kevin -
How to find the number simultaneous call at a given moment on UCCX ?
Hello,
I would to know how to find the number simultaneous call at a given moment on UCCX ?
it's on UCCX or UCCX RTMT, I don't know thanks a lot for your help.
AubertHi Gergely,
I should made a report on the number simultaneous call at a given moment on UCC on the server (all calls on the server).. -
FM to find the number of fiscal weeks in a year
Hi All,
Can anyone pls give me the function module to find the number of fiscal weeks in the given year.
Thanks,
Rajani.Eric Cartman wrote:
Ámit Güjärgoüd wrote:
> > Eric,
> >
> > Did you actually enjoy 2004 ?
wasn't bad...
do you mean, there were 53 weeks in that year? because I have concern, how it is actually counted...
wasn't bad... :)
Thats sounds Sweet
do you mean, there were 53 weeks in that year?
Yes
because I have concern, how it is actually counted...
If in a leap year fabruary falls in 5 weeks then that is the only possibility for 53 weeks
Cheers
PS:But No logic would be applied in this case -
Finding the number of days excluding weekends
Dear All,
I want to find the date difference between the working days,
ex, take 2 dates, today - Monday 11th and Monday 18th,
So, I want a function module which will calculate the difference between working days, means from 18th to 11th, it should calculate the difference as 5 working days.
Please let me know the function module which will show the number of difference in working days.
Thanks in Advance,
RamanaHi,
Check the following code:
REPORT ZDATEDIFF.
DATA: EDAYS LIKE VTBBEWE-ATAGE,
EMONTHS LIKE VTBBEWE-ATAGE,
EYEARS LIKE VTBBEWE-ATAGE.
PARAMETERS: FROMDATE LIKE VTBBEWE-DBERVON,
TODATE LIKE VTBBEWE-DBERBIS DEFAULT SY-DATUM.
call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
exporting
i_date_from = FROMDATE
i_date_to = TODATE
I_FLG_SEPARATE = ' '
IMPORTING
E_DAYS = EDAYS
E_MONTHS = EMONTHS
E_YEARS = EYEARS.
WRITE:/ 'Difference in Days ', EDAYS.
WRITE:/ 'Difference in Months ', EMONTHS.
WRITE:/ 'Difference in Years ', EYEARS.
INITIALIZATION.
FROMDATE = SY-DATUM - 60.
Regards,
Bhaskar -
How to find the number of decimals in a given value
Hi all,
Can u please help me in solving the problem,
i have a value called 5987.45
and decimal places are 45 that is 2 numbers
2) 765.987
number of digits in decimals are 3.
3) 67543.1
number of digits in decimals are 1.
for this i need a coding
thanks.Hi,
While printing your text element give as;
&wa_tab-dec_value(.2C)&
This will always print everything with 2 decimals.
Regards
Karthik D -
How to get the number of days in a month?
hi all
is there any way to get the number of days in a given month with a given year? for instance, if year is 2004 and the month is July or February, how can i get the number of days? thanks.Gee, I don't know ... Maybe this:
Calendar cal = Calendar.newInstance();
cal.set(Calendar.YEAR, 2004);
cal.set(Calendar.MONTH, Calendar.FEBUARY);
System.out.println("max days in month: " + cal.getActualMaximum(Calendar.DAY_OF_MONTH));
Do you not bother reading what people have already posted? Read the API docs on the Calendar class. -
How to find the number of idocs generated for a customer on the basis of his purchase order in a day ?
Dear Friends,
I am absolutely agree with your answer .
But my question is,
Lets say.....
One customer sending X number of purchase orders in a day , so how many IDocs generated on that specific day for that specific customer .
So, Question is , How can we find the no of sales orders(IDocs) generated for the customers on the specific day ?
Hope you all understood my requirement .
Thanks & Regards,
Aditya -
How to find the number of references created for a given object ??
How to find the number of references created for a given object in a big application environment.
That means, if i give any object name (of my application) as input, then how can i find the[b] number of references created for that particular object ??Please do not post the same question multiple times.
As for your original question, there is no direct way to do it.
Especially not the way you phrased it,
since objects don't have "names".
Applications also don't have "names".
They have classes and instances.
Also, there are 2 related issues, and I'm not sure which one is the one you asked.
#1. Finding the number of references to the same object.
Eg.
Map<String,String> a = new HashMap<String,String>();
Map<String,String> b = new HashMap<String,String>();
Map<String,String> c = a;In this case, there are only 2 objects.
The first object has (at least) 2 references pointing to it.
The second object has (at least) 1 reference pointing to it.
(There may be more, if the HashMap library keeps
references to these things, or if the HashMap object has
some internal cyclic references...)
If you're asking this, then it can't be done.
It's an active research topic in universities
and software research labs, called "alias analysis".
Type it in google, and you'll see people are working hard
and having little success so far.
#2. Finding the number of instances created from a class.
In this case, what you have to do is to add a counter to
the constructor of the class. Every time an object is constructed,
you increment the counter. Like this:
class MyClass
public static int counter = 0;
public MyClass( ) { counter++; }
// Then later in your program, you can do this:
MyClass a = new MyClass();
MyClass b = new MyClass();
System.out.println(MyClass.counter); // It should show 2Note: you won't be able to do this to every class in the system.
For every class you care about, you have to modify its constructor.
Also: when an object is deleted, you won't always know it
(and thus you won't always be able to decrement the counter).
Finalizers cannot always work (read Joshua Bloch's
"Effective Java" book if you don't believe me), but basically
(1) finalizers will not always be called, and
(2) finalizers can sometimes cause objects to not be deleted,
and thus the JVM will run out of memory and crash -
How to calculate the number of days worked for a given period
I need to calculate the number of days worked by contractor employees for a time period to be entered by a user. I am building a query on an infoset which contains employee information including contract start date and contract end date for the employee.
Ideally I'd like the user to enter the time period which should be reported on e.g. 01.08.2009 to 31.08.2009
The report should then identify all the contractor employees which were working during this period and to work out how many days they worked during this period. Obviously the contract start and end dates could fall both inside and outside the reporting period.
Can this be done and if so, do you have any suggestions as to how to do it?
Thanks.hi
So here you will first have to load the master data table employee in one internal table and read this table with the variables entries.
Your code in the reporting exit should look like that.
bye
data : wa_employee type /bi0/pemployee.
When 'ZDATE1'
if i_step = 2.
LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZDATE2'.
clear l_s_range.
clear wa_employee
1- select the entries from table employees
select single employee dateto datefrom
from /bi0/pemployee
into corresponding fields of wa_employee
where dateto le loc_var_range-low
and datefrom ge loc_var_range-high.
if sy-subrc eq 0.
CALL FUNCTION 'FIMA_DAYS_BETWEEN_TWO_DATES'
EXPORTING
i_datum_von = wa_employee-datefrom
i_kz_ult_von = 'X'
i_datum_bis = wa_employee-dateto
i_kz_ult_bis = 'X'
i_szbmeth = '1'
IMPORTING
e_tage = no_days.
l_s_range-low = no_days.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
ENDIF.
ENDIF.
endloop.
ENDIF.
Boujema -
How to find the number of references to an object in a big application
How to find the number of references created for a given object in a big application environment.
That means, if i give any object name (of my application) as input, then how can i find the[b] number of references created for that particular object ??Please don't post the same question multiple times.
I've answered your question in the other thread here:
http://forum.java.sun.com/thread.jspa?messageID=4312939 -
How to get the number of days of February.....
Hi ,
how can I get the number of days (28 or 29) of February of the current year or the next...????
Or is there any other way to find that a year is a leap or not (i mean the year has 365 or 366 days).??
Thanks
Simonselect add_months(to_date('&v_year', 'YYYY'), 12) -
to_date('&v_year', 'YYYY') from dual;Jens, it seems we have made the same mistake, trunc usage seems mandatory :
SQL> ed
Wrote file afiedt.buf
1* select add_months(to_date('2007', 'YYYY'), 12) - to_date('2007', 'YYYY') from dual
SQL> /
ADD_MONTHS(TO_DATE('2007','YYYY'),12)-TO_DATE('2007','YYYY')
366
SQL> ed
Wrote file afiedt.buf
1* select add_months(trunc(to_date('2007', 'YYYY'), 'YYYY'), 12) - trunc(to_date('2007', 'YYYY'), 'YYYY') from dual
SQL> /
ADD_MONTHS(TRUNC(TO_DATE('2007','YYYY'),'YYYY'),12)-TRUNC(TO_DATE('2007','YYYY')
365
SQL> Just to clarify my past doubt.
Nicolas. -
Finding the number of connected components in a graph
I don't know haow many people have seen this problem posted on c.d.o.m, but here is the essence
given an equivalence relation, e.g.
x y
1 1
2 2
2 1
1 2
3 3
find the number of equivalence classes. In this example equivalence classes are {1,2} and {3}.The idea: Label all the graph nodes with distinct primes. Find all simple paths in the graph weighted with product of nodes. Find the skyline of all maximal products. Count them.
Implementation (swithced to boolean vectors instead of primes)
create table input as (
select 1 x, 2 y from dual
union
select 2, 3 from dual
union
select 2, 4 from dual
union
select 6, 7 from dual
union
select 8, 9 from dual);
with TC as (
select connect_by_root(x) x, y
from (
select x,y from input
union
select y,x from input
) connect by nocycle x = prior y
), weightedNodes as (
select node, power(2,rownum-1) code
from (select x node from input
union select y node from input )
select count(distinct code) from (
select x,y,sum(code) code from (
select distinct pre.x, pre.y mid, post.y from TC pre, TC post
where pre.y=post.x
), weightedNodes
where node = mid
group by x,y
drop table input; -
Where to find the number of files in a folder (in Finder)?
I just upgraded from Snow Leopard.
In the past I could look at the bottom of the finder window and see how many files where in a particular folder. And how much megawattage they respresented in total.
Is there some kind of preference I can set in Mountain Lion to be able to see the 'number' of files in a given folder?
All ears,
BenThank you Kurt,
You're an ace.
Much appreciated.
Ben -
How to find the number of pending messages in a Queue
All,
Is there a way to find the number of pending messages in a given QUEUE to be picked by the queue reader?
My reader is not picking all the messages as many sent by my writer, i am not sure where they are getting lost? or if the JMS implementation is buffering them and does not flush until it does not have enough to throw out ( which any way does not make sense!!).
Please help.
ChandraYou're right in thinking that the behaviour you describe looks wrong.
Take a look at the QueueBrowser interface which can be used to inspect a queue. You get one using QueueSession.createBrowser(Queue). The QueueBrowser allows you to scan a queue without consuming the messages. However note that the state of the queue may change while you're observing it through the QueueBrowser so what you see might not always be a 100% accurate representation of the queue at any given time.
Other things to check:
- message selectors - are you setting a message selector on your queue receiver which is resulting in not all of the messages 'matching'.
- expired messages - are you setting a time-to-live on the messages that you publish.
Hope this helps,
David Ingham
http://www.arjuna.com
Maybe you are looking for
-
Please Help, Can't Connect
Help! I purchased 2 MacBooks for my daughters for Christmas. We were not able to connect via wireless to our WEP secured network. That day we spent endless hours talking to our DSL provider SBC and Apple both pointing the finger at each other regardi
-
Hello Sir/Madam, lpz tell me, in table VBAK what is the meaning of "distribution channal" , "division" & "plant".
-
Programming the mouse DIRECTLY
Hi I need some help, I have written a Java program that interfaces to some hardware using the parallel port and a mouse encoder. I am reading the mouse position just using standard Java event handling, which I thought was going to be ok until I reali
-
When I try to access Lightroom help from the help menu I get a windows message that "windows cannot find.............adobe lightroom\resources\fr\help\help.html". I guess the problem is that I use an English version (the ....en\help\help.html is actu
-
Hi guys, I need to create an action. A simple one. The idea: One path is selected, a user runs the action, it makes a copy of that path, moves the copy, select both the path and its copy and makes a blend. I tried to record that action, but Illustrat