Results 41 to 60 of 89
- 05-19-2012, 02:40 AM #41
Member
- Join Date
- May 2012
- Posts
- 28
- Rep Power
- 0
- 05-19-2012, 02:59 AM #42
Senior Member
- Join Date
- Apr 2012
- Posts
- 115
- Rep Power
- 0
Re: Java
sorry I was in a rush with that last message I hope it made sense.
when you get an error during execution that stops the program its called an unresolved runtime error (when you cant run the program its a compilation error). Eclipse should give you some red writing indicating what went wrong. this is actually the stack trace. if you get errors in the future and want someone to help you figure it out please post the output and stack trace for us.
I have an assignment for you if you're interested involving the switch statement and for loops.
- 05-19-2012, 03:29 AM #43
Member
- Join Date
- May 2012
- Posts
- 28
- Rep Power
- 0
- 05-19-2012, 03:51 AM #44
Senior Member
- Join Date
- Apr 2012
- Posts
- 115
- Rep Power
- 0
Re: Java
Its not advanced but you do need to understand loops and the switch statement, its a rewarding early program to do.
It's called the 12 days of christmasu. basically you want to print out all the verses (you can look them up on google) of the song.
you store each line of text in a string, the loop will print each verse and the switch statement will print all the lines for that verse.Legend has it the moderators and senior members of java-forums.org were able to code skyrim using only 701 lines of java... or so the legend goes.
- 05-19-2012, 07:58 AM #45
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,421
- Blog Entries
- 7
- Rep Power
- 17
- 05-19-2012, 04:17 PM #46
Senior Member
- Join Date
- Apr 2012
- Posts
- 115
- Rep Power
- 0
Re: Java
Legend has it the moderators and senior members of java-forums.org were able to code skyrim using only 701 lines of java... or so the legend goes.
- 05-19-2012, 07:32 PM #47
Member
- Join Date
- May 2012
- Posts
- 28
- Rep Power
- 0
- 05-19-2012, 08:02 PM #48
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,421
- Blog Entries
- 7
- Rep Power
- 17
- 05-19-2012, 08:26 PM #49
Member
- Join Date
- May 2012
- Posts
- 28
- Rep Power
- 0
- 05-19-2012, 08:31 PM #50
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,421
- Blog Entries
- 7
- Rep Power
- 17
- 05-19-2012, 09:06 PM #51
Member
- Join Date
- May 2012
- Posts
- 28
- Rep Power
- 0
Re: Java
can i have, like a hint on how to do this? 'cause im racking my brain trying to do this but one i start trying i draw a blank, i feel like i should know this but i guess i don't.
also let me see if i got this right:
a for loop would be like this-and a switch statement is like -Java Code:for(int i = 1; i<11;i++){System.out.println("Count is" + i);}Java Code:int age = 3; switch (age){ case 1: System.out.println("You can crawl"); break; case 2: System.out.println("you can talk"); break; case 3: System.out.println("you can use the toilet"); break; default: System.out.println("Yoou too old."); break;
- 05-19-2012, 09:14 PM #52
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,421
- Blog Entries
- 7
- Rep Power
- 17
Re: Java
Suppose you have twelve cards, all with text on them: "a partridge in a pear tree", "two turtle doves", "three french hens" etc. also you have a choir in front of you that doesn't know the text of the song. Write down the number of the cards (1 ... 12) in the correct order you have to show to make the choir sing the song.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 05-19-2012, 09:39 PM #53
Member
- Join Date
- May 2012
- Posts
- 28
- Rep Power
- 0
Re: Java
i think this project is to difficult for me :/ could i get something easier? maybe something that will get me used to using for loops and switch statements? but doesnt require a bunch of lines of code (bunch >=20)
-
Re: Java
Perhaps it would be better if you just bought a book on Java, like the Head First Java, and then move through the book one page and chapter at a time, not skipping a page until you've completed the whole thing. This way you will progress by baby steps with each subsequent step building on your knowledge gained from the previous steps.
- 05-19-2012, 09:58 PM #55
Member
- Join Date
- May 2012
- Posts
- 28
- Rep Power
- 0
-
Re: Java
Last edited by Fubarable; 05-19-2012 at 10:06 PM.
- 05-19-2012, 10:16 PM #57
Member
- Join Date
- May 2012
- Posts
- 28
- Rep Power
- 0
- 05-19-2012, 11:00 PM #58
Member
- Join Date
- May 2012
- Posts
- 28
- Rep Power
- 0
Re: Java
this is all i could get
i cant figure out how to mkae it say second and then third ect.. in place of the first day of christmas, also cant figure out how to mkae it repeat the last verse after the new one (example - first verse A partridge in a pear tree - second verse Two turtle doves --repeat-- A partridge in a pear tree)Java Code:class Christmas { public static void main(String[] args){ for(int verse = 1; verse<13;verse++){ System.out.println("On the first day of chirstmas my true love gave to me"); switch(verse){ case 1: System.out.println("A partridge in a pear tree"); break; case 3: System.out.println("Two turtle doves"); break; case 4: System.out.println("Three French hen"); break; case 5: System.out.println("Five golden rings"); break; case 6: System.out.println("Six geese a-laying"); break; case 7: System.out.println("Seven swans a-swimming"); break; case 8: System.out.println("Eight maids a-milking"); break; case 9: System.out.println("Nine ladies dancing"); break; case 10: System.out.println("Ten lords a-leaping"); break; case 11: System.out.println("Eleven pipers piping"); break; case 12: System.out.println("Twelve drummers drumming"); break; } } } }
- 05-20-2012, 12:10 AM #59
Senior Member
- Join Date
- Apr 2012
- Posts
- 199
- Rep Power
- 0
Re: Java
Well, you would have to replace the string in quotes with several strings that are concatenated together:
"On the" + day[verse]+ "of chirstmas my true love gave to me"
and then declare day as:
Java Code:private static String[] day = {"first","second","third","forth","fifth","sixth","seventh","eighth","ninth","tenth","eleventh","twelfth","thirteenth"};
- 05-20-2012, 12:12 AM #60
Member
- Join Date
- May 2012
- Posts
- 28
- Rep Power
- 0


6Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks