Off Topic: The Flood
This topic has moved here: Subject: More Computer Science help!
  • Subject: More Computer Science help!
Subject: More Computer Science help!

"Your eyes are full of hate, forty-one. That's good. Hate keeps a man alive. It gives him strength"

Write a Java method that takes three integer values (a month, a day, and a year) as arguments and
returns the number of that day in the year (an integer between
1 and 365, or 366 for leap years).
Your method should have the following header:

public static int dayNum (int month, int day, int year)

To calculate the day number for a given date, use the following formula:

a. dayNum = 31 x (month - 1) + day

b. If the month is after February (2), then subtract (4 x month + 23)/10 from dayNum.

c. If the year is a leap year and the date is after February 29, add 1 to dayNum.

  • 12.15.2012 7:15 PM PDT
  • gamertag: [none]
  • user homepage:

public bool DoYourOwnHomework ()
{
-----bool OpIsLazy;
-----OpIsLazy = true;
-----return OpIsLazy;
}

you have it written out in 3 steps. yet you want someone from the flood to put it together for you?

but here you go. way to learn

public static int dayNum ( int month , int day , int year )
{
-----int dayNum = 31 * ( month - 1 ) + day;
-----if ( month > 2 )
-----{
----------dayNum -= ( 4*month+12)/10;
-----}
-----if ( (year%4) == 0 && (month >= 2 && day > 29) || (month > 2 %% day >= 1) )
-----{
----------dayNum += 1;
-----}
}



[Edited on 12.15.2012 7:38 PM PST]

  • 12.15.2012 7:19 PM PDT

Key

YouTube, OP. 1 is good but 2's a crowd.

  • 12.15.2012 7:20 PM PDT

"Your eyes are full of hate, forty-one. That's good. Hate keeps a man alive. It gives him strength"


Posted by: Exception Thrown
public bool DoYourOwnHomework ()
{
-----bool OpIsLazy;
-----OpIsLazy = true;
-----return OpIsLazy;
}

you have it written out in 3 steps. yet you want someone from the flood to put it together for you?



Its not that I'm lazy, its that I was a very bad student this semester and don't know how to do it.

  • 12.15.2012 7:23 PM PDT
  • gamertag: [none]
  • user homepage:

I use a signature because I can

If(homework < your mind)
{
lblOutput.Text = "Please change your major";
}
else
{
lblOutput.Text = "Do your homework";
}

  • 12.15.2012 7:25 PM PDT

Sounds like a Calendar object is what you should be looking at, but it looks like the assignment has given you some conditional requirements to check for.

[Edited on 12.15.2012 7:28 PM PST]

  • 12.15.2012 7:27 PM PDT

"Your eyes are full of hate, forty-one. That's good. Hate keeps a man alive. It gives him strength"


Posted by: CostlyAxis
Sounds like a Calendar object is what you should be looking at, but it looks like the assignment has given you some conditional requirements to check for.



Thats beyond what we've been doing, its an intro course

  • 12.15.2012 7:31 PM PDT
  • gamertag: [none]
  • user homepage:

public static int dayNum ( int month , int day , int year )
{
-----int dayNum = 31 * ( month - 1 ) + day;
-----if ( month > 2 )
-----{
----------dayNum -= ( 4*month+12)/10;
-----}
-----if ( (year%4) == 0 && (month >= 2 && day > 29) || (month > 2 && day >= 1) )
-----{
----------dayNum += 1;
-----}
}


Ok here you go. I'm pretty sure this is right. at the very least its mostly right. So I imagine you would get more points than not completing it at all

[Edited on 12.15.2012 7:41 PM PST]

  • 12.15.2012 7:32 PM PDT

"Your eyes are full of hate, forty-one. That's good. Hate keeps a man alive. It gives him strength"


Posted by: Exception Thrown

Ok here you go. I'm pretty sure this is right.


I got part of that on my own, but you helped fill in the blanks, thank you. I'm definitely going to try and do better next semester, I haven't transitioned well from high school

  • 12.15.2012 7:36 PM PDT
  • gamertag: [none]
  • user homepage:


Posted by: KUZOKU85

Posted by: Exception Thrown

Ok here you go. I'm pretty sure this is right.


I got part of that on my own, but you helped fill in the blanks, thank you. I'm definitely going to try and do better next semester, I haven't transitioned well from high school


this part?

if ( (year%4) == 0 && (month >= 2 && day > 29) || (month > 2 && day >= 1) )

if the year modulus 4 == 0 then the year is a leap year.

and (month is GREATER THAN OR EQUAL to 2 AND day is GREATER THAN 29) OR ( month is GREATER THAN 2 AND day is GRATER THAN OR EQUAL to one )

also make sure to fix the error of the %% in there instead of &&

[Edited on 12.15.2012 7:42 PM PST]

  • 12.15.2012 7:40 PM PDT

"Your eyes are full of hate, forty-one. That's good. Hate keeps a man alive. It gives him strength"


Posted by: Exception Thrown

Posted by: KUZOKU85

Posted by: Exception Thrown

Ok here you go. I'm pretty sure this is right.


I got part of that on my own, but you helped fill in the blanks, thank you. I'm definitely going to try and do better next semester, I haven't transitioned well from high school


this part?

if ( (year%4) == 0 && (month >= 2 && day > 29) || (month > 2 && day >= 1) )

if the year modulus 4 == 0 then the year is a leap year.

and (month is GREATER THAN OR EQUAL to 2 AND day is GREATER THAN 29) OR ( month is GREATER THAN 2 AND day is GRATER THAN OR EQUAL to one )

also make sure to fix the error of the %% in there instead of &&


Yeah, I actually had the leap year code already figured out in an earlier method in the project but I didn't think to use it, I know, I've very retarded

  • 12.15.2012 7:43 PM PDT