| | |
Absolute no brainer
![]() |
•
•
Join Date: Jun 2005
Posts: 14
Reputation:
Solved Threads: 0
Hey guys i hope someone can point me in the right direction
The problem
I have just started my first year in computer science and have just recieved my first java assignment. I know its really simple but i just cant get my head round it, the worse thing is, although it was simple stuff, i actually did some java last year so this SHOULD be a doddle. I have been looking for help online but because my lecturer thought it would be a good idea to start with applets i am finding that all the examples and tutorials are way above my head. there are whole chunks of jargon and code that i just dont understand (last year i did VERY SIMPLE applications)
the assignment
i have to create a simplified game of hangman or a program that will convert time from a 12 hour format to 24 hr format. I decided to do the clock thing because it sounds easier (i know i'm stupid lol).
when i'm in lectures i understand what is going on, and line by line i understand most of the example codes we have been given, but when i have to implement it i just dont know where to start
i was given this assignment a week ago. So far I have asked a mate to help, he's in his first year at a different uni, so he really couldnt offer much. i have also spent about 16hrs in total over the past week searching for online material that might help. I have spent all evening trying to find something that might help.
i'm not expecting anyone to write the code for me because i really do want to learn. Last year we worked from psuedo (sp?) code. if someone was to write that for me, would that be too much help?
i have made several rubbish attempts at writing the code but beyond declaring int variables for hrs mins and secs i am at a loss. i dont even know what methods i should use
p.s.... thanks for taking the time to read, if you got this far lol, i will check back as soon as i can as i have decided that 6 hours of total unproductivity (if thats even a word lol) is quite enough for one day and you guys really are my last hope at the moment
The problem
I have just started my first year in computer science and have just recieved my first java assignment. I know its really simple but i just cant get my head round it, the worse thing is, although it was simple stuff, i actually did some java last year so this SHOULD be a doddle. I have been looking for help online but because my lecturer thought it would be a good idea to start with applets i am finding that all the examples and tutorials are way above my head. there are whole chunks of jargon and code that i just dont understand (last year i did VERY SIMPLE applications)
the assignment
i have to create a simplified game of hangman or a program that will convert time from a 12 hour format to 24 hr format. I decided to do the clock thing because it sounds easier (i know i'm stupid lol).
when i'm in lectures i understand what is going on, and line by line i understand most of the example codes we have been given, but when i have to implement it i just dont know where to start
i was given this assignment a week ago. So far I have asked a mate to help, he's in his first year at a different uni, so he really couldnt offer much. i have also spent about 16hrs in total over the past week searching for online material that might help. I have spent all evening trying to find something that might help.
i'm not expecting anyone to write the code for me because i really do want to learn. Last year we worked from psuedo (sp?) code. if someone was to write that for me, would that be too much help?
i have made several rubbish attempts at writing the code but beyond declaring int variables for hrs mins and secs i am at a loss. i dont even know what methods i should use
p.s.... thanks for taking the time to read, if you got this far lol, i will check back as soon as i can as i have decided that 6 hours of total unproductivity (if thats even a word lol) is quite enough for one day and you guys really are my last hope at the moment
•
•
Join Date: Jun 2005
Posts: 14
Reputation:
Solved Threads: 0
not really very helpful but i do really appreciate it... my problem is a little more complex than i have made it sound i guess lol... i have been trying to write this program from start to finish and i think that mite be my problem... after a brain explosion last nite i decided to do all the bits i think i know about (even tho it wont work) and then maybe ask for help for the missing parts
thanks again, i do appreciate people trying to help
thanks again, i do appreciate people trying to help
writing pseudocode and problem solving is all part of programming & software development (And if you haven't tried to write pseudocode for this problem yet, then I suggest you give it a go, and see if that helps!), so I'm not going to write a complete comprehensive solution, although, its equally true that the best way to get your head around a problem you've been sweating over is to find a fresh brain to skim over it.
Here's how I would approach the problem:
What does the input look like? You should make sure you have this well-defined. the first hurdle might be string manipulation, eg, if you've got to extract several elements from a string such as "09:45am", then you probably want to search for the delimiter : which seperates the numbers, and extract the two numerical parts as ints, then extract the am/pm suffix to a String
Alternatively, you could leave that bit til last, and just have each part input seperately by the user - in which case, the problem should be more trivial. If your suffix is "am", then the hours remain the same. if your suffix is "pm", then you need to add 12 to your hours. minutes remain the same regardless, and the suffix isn't used in 24hr time.
Finally, what does the output look like? you could simply concatenate hours & minutes for 'military' time format, eg "2315", or perhaps add a seperator in the middle - "23:14".
if string manipulation is proving tricky (String manipulation in java is a bit awkward IMHO), try creating that seperately in another program while you work out how to break up your input to seperate components. good luck!
Here's how I would approach the problem:
What does the input look like? You should make sure you have this well-defined. the first hurdle might be string manipulation, eg, if you've got to extract several elements from a string such as "09:45am", then you probably want to search for the delimiter : which seperates the numbers, and extract the two numerical parts as ints, then extract the am/pm suffix to a String
Alternatively, you could leave that bit til last, and just have each part input seperately by the user - in which case, the problem should be more trivial. If your suffix is "am", then the hours remain the same. if your suffix is "pm", then you need to add 12 to your hours. minutes remain the same regardless, and the suffix isn't used in 24hr time.
Finally, what does the output look like? you could simply concatenate hours & minutes for 'military' time format, eg "2315", or perhaps add a seperator in the middle - "23:14".
if string manipulation is proving tricky (String manipulation in java is a bit awkward IMHO), try creating that seperately in another program while you work out how to break up your input to seperate components. good luck!
Last edited by Bench; Nov 4th, 2006 at 5:54 am.
¿umop apisdn upside down? ![]() |
Similar Threads
- Link to tutorial for absolute beginners (C++)
- 2 Good Books for absolute beginners... (C++)
- Quickie on positin:absolute (HTML and CSS)
- call absolute in QBasic (Legacy and Other Languages)
Other Threads in the Java Forum
- Previous Thread: I need java test codes
- Next Thread: Another Java Noob :(
| Thread Tools | Search this Thread |
android api applet application apps array arrays automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) card chat class classes client code collision columns component constructor crashcourse database designadrawingapplicationusingjavajslider draw eclipse error errors eventlistener exception expand fractal game givemetehcodez graphics gui guidancer html ide image inetaddress integer intellij j2me java javafx javamicroeditionuseofmotionsensor javaprojects jme jni jpanel jtree julia linux list loop machine map method methods mobile mobiledevelopmentcreatejar myaggfun netbeans newbie oracle physics plazmic print problem program programming project recursion scanner server set sharepoint smart sms smsspam sort sortedmaps sql string subclass support swing textfield threads tree trolltech unlimited utility webservices windows





