/    Sign up×
Community /Pin to ProfileBookmark

help on a 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).

to post a comment
Java

10 Comments(s)

Copy linkTweet thisAlerts:
@Khalid_AliOct 02.2006 — 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)
Copy linkTweet thisAlerts:
@saeOct 02.2006 — No problem with helping you with your homework man, but you gotta do all the work. haha
Copy linkTweet thisAlerts:
@james12authorOct 02.2006 — 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);

}
Copy linkTweet thisAlerts:
@james12authorOct 02.2006 — 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
Copy linkTweet thisAlerts:
@WaylanderOct 03.2006 — 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.
Copy linkTweet thisAlerts:
@agent_x91Oct 03.2006 — For a start, the first line has a typo in it:


mport javax.swing.*;
[/QUOTE]


Should be [I]import[/I] javax.swing.*

?
Copy linkTweet thisAlerts:
@james12authorOct 04.2006 — 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
Copy linkTweet thisAlerts:
@saeOct 04.2006 — 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.");
[/quote]

The above code will print exact what is in quotes. As date1 and date2 are variables, you want to make the code like this:
<i>
</i>System.out.println(date1 + " is earlier than " + date2);
Copy linkTweet thisAlerts:
@WaylanderOct 05.2006 — Someone delete this thread.
Copy linkTweet thisAlerts:
@agent_x91Oct 09.2006 — Try it for yoruself and we'll help you fix any problems you may have. But I for one am [B]not[/B] going to make an entire program for you because you can't be bothered to do your homework.
×

Success!

Help @james12 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...