Results 1 to 8 of 8
Thread: Array help
- 11-25-2010, 10:10 PM #1
Array help
Can any one help me plz
for school i have to make the following program with arrays command-line argument
The program must ask me the number of days and show me the date as result
This is the result of the program as shown under
tnx every one
__________________________________
java Days 123
day 123 is 3 May
java Days 365
day 365 is 31 December
java Days 1
Day 1 is 1 january
-
Hello, and welcome to the forum.
So in essence what you've done is to give us your entire assignment without asking a question and without showing any evidence of effort on your part, and I'm afraid that in this situation there's not much that we can do for you other than to direct you to a tutorial or two.
I suggest that you post your best solution that you've created so far, and ask as specific questions as possible, and we'll be much better able to help. If you really have no idea how to begin here, then please have a look here: Starting Writing a Program. It's a well-written article that can help.
Much luck
- 11-26-2010, 12:41 PM #3
Tnx alot Fubarable
HERE is the program i have written so far, and further have no idea
public class Dagen{
public static void main (String arg []){
if (arg.length < 1){
System.out.println("Aantal argument is fout!");
}
else {
int DAG_MAAND [] = {31,28,31,30,31,30,31,31,30,31,30,31};
int sum = 365 - ;
String MAAND [] = {"januari", "februari", "maart", "april", "mei", "juni", "juli","augustus", "september", "oktober", "november", "december"};
System.out.println(MAAND[Integer.parseInt(arg[0])]);
}
}
}
- 11-26-2010, 01:01 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,476
- Rep Power
- 16
So...what happens when you run that?
- 11-26-2010, 01:44 PM #5
- 11-26-2010, 01:52 PM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,476
- Rep Power
- 16
?
Does it throw an exception or what?
- 11-26-2010, 03:45 PM #7
Member
- Join Date
- Oct 2010
- Posts
- 94
- Rep Power
- 0
I'd do something like:
Check whether 'number of days' is greater than 'number of days in first month' if so decrease 'number of days' by 'number of day of first month' and repeat with next month. If not print "'number of days' is 'number of days' 'first month'"
Hm, a little cryptic but you can do some thinking as well I guess. :)
ErikI'm new to Java but I like to help where ever I can. :)
- 11-26-2010, 07:14 PM #8
Similar Threads
-
Variable of an object in an array compared to an element of another array?
By asmodean in forum New To JavaReplies: 23Last Post: 09-07-2010, 08:12 PM -
Trying to make an array list // inserting an element to middle of array
By javanew in forum New To JavaReplies: 2Last Post: 09-06-2010, 01:03 AM -
Convert Char Array to String Array
By Mayur in forum New To JavaReplies: 8Last Post: 10-12-2009, 11:41 AM -
Array length and printing out uninitialized array.
By nicolek808 in forum New To JavaReplies: 4Last Post: 09-10-2009, 09:12 AM -
How to add an integer to a array element and the store that backinto an array.
By Hannguoi in forum New To JavaReplies: 1Last Post: 03-31-2009, 06:40 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks