Andres Soto

Greenhorn
+ Follow
since Nov 03, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Andres Soto

Yes yes! But that's the problem I don't know how to keep track of that. How would I go about doing this? I have to increment the start date? How do I do this? Please, I really need the help. This is the last step in my assignment. I already completed the tester class and everything I just need to to fix/complete the loop. Thank you
12 years ago
I changed it to



I want to return the amount of times that startnext occurred since thats equal to the amount od days between the two dates right?
12 years ago
Can you help me fix this loop please?


These are the methods

Accessor Methods

d1.getMonth() // returns the month as int 1..12
d1.getDay() // returns the day of the month, as an int
d1.getYear() // returns the year

d1.getMonthName() // returns the month as a String (e.g. “March") d1.getDayOfWeek() // returns the day of the week as a string (e.g.,
// “Friday”)

d1.equals(d2) // returns true if d1 is the same date as d2
// otherwise, returns false

d1.getShortDate() // returns the date as mm/dd/yyyy
d1.getMediumDate() // returns the date in the form of
//“November 2, 2010”
d1.getLongDate() // returns the date in the form of
// “Monday, November 2nd, 2010”

Mutator Methods

Date d = new Date(1,1,2012) ; // d is January 1, 2012 (a leap year)

d.next() ; // d is January 2, 2012
d.previous() ; // d is January 1, 2012
d.add(31) ; // d is February 1, 2012
d.subtract(32) ; // d is December 31, 2011
d.next() ; // d is January 1, 2012

d = new Date(3,1,2012) ; // d is March 1, 2012
d.previous() ; // d is now February 29, 2012

I think I see the logic error with my code. It will be infinite right? How can I fix it though?
12 years ago
Thank you aj! There was a logic error located in the loop but i fixed and got iy to run! Thank you very much!
12 years ago
I HAVE TO USE
d1.getShortDate() // returns the date as mm/dd/yyyy


And test class
12 years ago
My professor said to use this.
d1.getShortDate() // returns the date as mm/dd/yyyy
How would I use that?
12 years ago
Someone told me I have to use SimpleDateFormat
This is the loop that checks for the fourth thursday of november (thankgiving)


public Date getThanksgiving(int year)
{

Date Thanksgiving = new Date(11, 1, year);

int count = 1 ;
int weekCount = 0;
for ( ; count <= 30; count++)
{
if (Thanksgiving.getDayOfWeek().equals("Thursday")) {
weekCount++;
}
if (weekCount == 4) {
break;
}


}



This is the test class


SpeedDating thanksgiving = new SpeedDating() ;

input = JOptionPane.showInputDialog
("Enter the year for november ") ;

int year = Integer.parseInt(input) ;

System.out.println(thanksgiving.getThanksgiving(int year));



Basically the user inputs a year and my program supposed to print the date. For example, if the user inputs 2012 then my program will print out 11,22,2012. However my program is printing out something like Date@1ea0105 which someone told me was a reference (memory location). How can I fix this? Thank you.
12 years ago
I'm sorry this is my first semester to programming. And I'm having a lot of trouble. Should I repost so I can shorten the code? And what do you mean to get rid of the date constructor? I heard yo must use SimpleDateFormat or something like that in order to convert the date to a string. The problem is that I'm printing out the reference (memory location or something like that). But I have no Idea how to use the SimpleDateFormat. Can you help me? Thank you
12 years ago



Why can't I print out the date for thanksgiving? Thank you.
12 years ago