This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NEED HELP

 
samen jaames
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi how's everyone doin...
i working on this program and i need submit this by tomrr. so please help as much as you can following is the Description (it's long program),

Program Description:
Given an input data file containing dates, one date per line, write a Java application Project.java which
will read lines of text from data file and put them into a partially-filled array of strings, and will then print
the contents of the array to a series of three JOptionPane message dialog boxes with text areas. The
first message box will display a column of the dates in the original order in which they were listed in the
file. The second message box will display a column of the dates sorted in lexicographical order, as
strings. The third message box will display a column of the dates in ascending order by date (earliest
date first).

Program should contain the following methods:

public static void main (String args[])
the main method for this program, it should call the
methods below as appropriate.

public static int readFile (String filename, String[] dates)
Reads from the file whose filename is given as a parameter, and fills array of strings
represending dates. Lines of the file that do not have proper date format (MM-DD-YYYY or
MM/DD/YYYY) or which represent invalid dates (such as 13/32/2006) should be rejected by
printing an error message to the console and not including them in the array. The test for validity
should be done by your isValidDate method below. The returned value is the number of dates
successfully put in the array.

public static void sortLines (String[] lines, int length)
Sorts the array of strings lexicographically using selection sort.

public static void sortDates (String[] dates, int length)
Sorts the array in date order using selection sort. In order to sort the date strings in order by
date, you will need to write an additional method called compareDate that will behave similarly
to compareTo method of the String class, except that it will sort by date rather than
lexicographically. To compare dates date, you will need to split the string into parts representing
the month, day, and year.

public static int compareDate(String date1, String date2)
compares two dates. Returns a negative number if date1 precedes date2, 0 if date1 is the
same as date2, or a positive number if date1 succeeds date2. This method is called from
within sortDate, which date strings by date.

public static void displayResults(String[] students, int length)
Prints the contents of the array to a JOptionPane.

public static boolean isValidDate(String date)
Returns true if and only if date has the proper format (MM-DD-YYYY or MM/DD/YYY) and has
appropriate values for the month (1 to 12) and day. Valid days may range from 1 to 31 in the
months of January, March, May, July, August, October, and December, and may range from 1
to 30 for the months of April, June, September, and November. In February, days may range
from 1 to 29 in a leap year, 1 to 28 in other years. Call your isLeapYear method, described
below, to determine whether a year is a leap year.

public static boolean isLeapYear(int year)
Returns true if and only if year is a leap year. A year is a leap year if it is a multiple of 400 or if
it is a multiple of 4 but not a multiple of 100.
---------------------------------------------------------
here's what i understood part of the program and i did pls help me with other parts.

 
Burkhard Hassel
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers,


samen jaames wrote:
i working on this program and i need submit this by tomrr. so please help as much as you can


As much as we can? Or as much as we want:
http://faq.javaranch.com/view?DoYourOwnHomework
http://faq.javaranch.com/view?UseAMeaningfulSubjectLine


devastater xil made some ad:
There are codes on this page that you might be interested in scad.conr



This tutorial is new and just about to be build up. It has nothing to do with the question of Samen. But in this case I think it's ok to post it here.




and for myself, i should look up this:
http://faq.javaranch.com/view?KeepItDown



;-)
Bu.
 
Henry Wong
author
Marshal
Pie
Posts: 21115
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at the requirements for the isValidDate() method.

public static boolean isValidDate(String date)
Returns true if and only if date has the proper format (MM-DD-YYYY or MM/DD/YYY) and has appropriate values for the month (1 to 12) and day. Valid days may range from 1 to 31 in the months of January, March, May, July, August, October, and December, and may range from 1 to 30 for the months of April, June, September, and November. In February, days may range from 1 to 29 in a leap year, 1 to 28 in other years. Call your isLeapYear method, described below, to determine whether a year is a leap year.


It must take a string, in a particular format. This is not the signature that you have for your method. What methods of the String class have you learned so far? You need to parse the date string from the format defined to the individual day, month, and year, before you can check for validity.

As for the other methods, show us what you have done so far. We can't give you any hints if we don't know what you are doing wrong.

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic