Click to See Complete Forum and Search --> : help on a program
james12
10-01-2006, 05:21 PM
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).
Khalid Ali
10-01-2006, 09:49 PM
if you want to learn the language then you will have to do a bit better then this...
At least try to write/come up with some sort of solution and then ask question to help you fill in the gaps...(Homework alert)
No problem with helping you with your homework man, but you gotta do all the work. haha
james12
10-02-2006, 12:50 AM
ok, here' what i understood and did, so now you guys help me out,
mport javax.swing.*;
public class pro1111
{
public static void main (String [] args)
{
TextFileInput in = new TextFileInput("Dates.txt");
TextFileOutput out = new TextFileOutput("Dates1.txt");
String line = in.readLine();
while ( line != null ) {
StringTokenizer st = new StringTokenizer(line, "/");
int monthNumber = Integer.parseInt(st.nextToken());
int day = Integer.parseInt(st.nextToken());
int year = Integer.parseInt(st.nextToken());
out.println(monthNumberToName(monthNumber)
+ " " + day + ", " + year);
line = in.readLine();
}
}
private static compareDate(string date1, string date2)
{
String date1 = "09/27/2004";
String date2 = "05/04/2002";
if (compareDate(date1, date2) < 0)
System.out.println("date1 is earlier than date2.");
return 0;
}
private static void display(short[] numbers,
int lengthFilled)
{
final String lineBreak = System.getProperty("line.separator");
// Create text area for output:
JTextArea textArea = new JTextArea();
textArea.setEditable(false);
// Print numbers to output text area:
for ( int i = 0; i < lengthFilled; i++ )
textArea.append(numbers[i] + lineBreak);
// Display the output text area via a message dialog box:
JOptionPane.showMessageDialog(null, textArea);
}
james12
10-02-2006, 12:49 PM
somebody help.........
i know it's wrong, so take my program (you don't need to do it for me), and put pointers, explation what i am doing wrong, what i need to add , and what need to removie. that's what i am asking, so look at the code and help
Waylander
10-02-2006, 10:38 PM
Doesnt really work like that hey, someone may do it but its a bit much to ask really.
Why dont you start at the top of the program and try to finish it your self.
Then if you run into a problem ask a specific question about the problem.
Waylander.
agent_x91
10-03-2006, 08:36 AM
For a start, the first line has a typo in it:
mport javax.swing.*;
Should be import javax.swing.*
:)
james12
10-04-2006, 02:54 AM
please hlep me write the program, and after wirting the program, you can put the notes in the code so i can understand the whole thing.
Thanks
James
We are not going to do your homework for you. As Waylander said, try it yourself and if you have a specific problem then ask. I don't think anyone here would have a problem answering specific questions. We would also gladly help you if you are having problems compiling.
I quickly went over you code and found another error.
System.out.println("date1 is earlier than date2.");
The above code will print exact what is in quotes. As date1 and date2 are variables, you want to make the code like this:
System.out.println(date1 + " is earlier than " + date2);
Waylander
10-04-2006, 09:20 PM
Someone delete this thread.
agent_x91
10-09-2006, 08:32 AM
Try it for yoruself and we'll help you fix any problems you may have. But I for one am not going to make an entire program for you because you can't be bothered to do your homework.