Java Forum / First Aid / March 2006
Java Gurus Help!
Andrew.Bell - 12 Mar 2006 14:29 GMT Below is what my assignment involves, could you basically point me in the right direction to help me acomplish the task set but not give me the acctual answer.
SCENARIO This assignment is based on a banking system. This mini bank will have 4 customers. The customers each have 4 different accounts (Current Account, ISA Savings Account, Mortgage and Car Loan).
Each customer should be represented as an array with 4 elements (Each element of the array will represent one of their accounts).
Each customer aray should be an array of intergers. Therefore all amounts in the accounts are interger values.
Your main program should allow the user to enter the initial amounts in each account for each customer and then selec from a menu in order to do the following tasks.
1.For a sepcific customer, display details of all their accounts. 2.Get the balance in an account for a specific customer. 3.Add to an account for a specific customer. 4. Withdraw from an account for a sepcified customer. 5.Get the total funds in all of the current accounts in the bank. 6.Get the total funds in all of the ISA's in the bank.
You are to plan, design and impliment and test the mini banking system.
Patricia Shanahan - 12 Mar 2006 15:49 GMT > Below is what my assignment involves, could you basically point me in the > right direction to help me acomplish the task set but not give me the > acctual answer. I've written some suggestions for how to get started on programming assignments, at
http://home.earthlink.net/~patricia_shanahan/beginner.html
Patricia
Mitch - 12 Mar 2006 16:23 GMT > I've written some suggestions for how to get started on programming > assignments, at > > http://home.earthlink.net/~patricia_shanahan/beginner.html > > Patricia These are some very good points and you should read them well!
I always found when I first started that pseudo code is your friend. Write sequentially in comments what it is you need to and space these points out, then fill in the gaps with code bit at a time.
For example it would begin
[code]
//Here I have to read in the info
//Here I need to display the info to show it is correct
//Here is need to implement a means of re-entering the info if it is //wrong (perhaps some form of loop? if more wrong info is input)
//Here I ...
[/code]
Then you fill in the first gap, compile it, test it, and when you are happy with it you can continue to the next section.
This method won't help you for big projects so much, but for smaller ones it can help ensure you know and are clear on what needs to be accomplished. If you ever have any focus on re-usability this is also a good way to start, put the code in each block into a method that can be called and then (say if later in life / class) you need another example of a method (which will iterate over an array and print the results you already have for example)you have a working example you can hopefully cut and paste (Or ideally use the import functions etc..)
This is from a relative newbie to another so I expect my methods to be criticised, but as a starter I did find the above methodology useful, so give it a try.
HTH
Mitch.
Mitch - 12 Mar 2006 16:26 GMT > I've written some suggestions for how to get started on programming > assignments, at > > http://home.earthlink.net/~patricia_shanahan/beginner.html > > Patricia These are some very good points and you should read them well!
I always found when I first started that pseudo code is your friend. Write sequentially in comments what it is you need to and space these points out, then fill in the gaps with code bit at a time.
For example it would begin
[code]
//Here I have to read in the info
//Here I need to display the info to show it is correct
//Here is need to implement a means of re-entering the info if it is //wrong (perhaps some form of loop? if more wrong info is input)
//Here I ...
[/code]
Then you fill in the first gap, compile it, test it, and when you are happy with it you can continue to the next section.
This method won't help you for big projects so much, but for smaller ones it can help ensure you know and are clear on what needs to be accomplished. If you ever have any focus on re-usability this is also a good way to start, put the code in each block into a method that can be called and then (say if later in life / class) you need another example of a method (which will iterate over an array and print the results you already have for example)you have a working example you can hopefully cut and paste (Or ideally use the import functions etc..)
This is from a relative newbie to another so I expect my methods to be criticised, but as a starter I did find the above methodology useful, so give it a try.
HTH
Mitch.
Mitch - 12 Mar 2006 16:28 GMT Apologies for the double post.
Andrew.Bell - 12 Mar 2006 16:40 GMT No problems about double post..
What it is is this is my project started, could someone please tell me if I'm doing anything wrong at all. I need criticism if I am doing anything wrong so that i can learn on where and what I need to do to my code to get it right.
This is my current code feel free to execute it.
//Andrew Bell public class MiniBank { public static void main(String args[]) { String title[] = {"Current Account ", "ISA ", "Mortgage ", "Car Loan"}; String ConfigMenu[] = {"A. For a specific customer, display details of their accounts.", "B. Get the ballance in an account for a specified customer.", "C. Add to an account for a specific customer.", "D. Withdraw from an account for a specified customer.", "E. Get the total funds in all of the current accounts in the bank.", "F. Get the total funds in all of the ISA's in the bank."};
char Choice; int Customer; char Answer ='y';
int[] Customer1; Customer1 = new int[4]; int[] Customer2; Customer2 = new int[4]; int[] Customer3; Customer3 = new int[4]; int[] Customer4; Customer4 = new int[4];
System.out.println(" "); System.out.println("Welcome To The Mini Bank"); System.out.println("------------------------"); System.out.println(" ");
for (int i=0; i<4; i++) { System.out.print("Please Enter Amount For Customer 1's " + title[i] + "= "); Customer1[i] = EasyIn.getInt(); } System.out.println(" ");
for (int i=0; i<4; i++) { System.out.print("Please Enter Amount For Customer 2's " + title[i] + "= "); Customer2[i] = EasyIn.getInt(); } System.out.println(" ");
for (int i=0; i<4; i++) { System.out.print("Please Enter Amount For Customer 3's " + title[i] + "= "); Customer3[i] = EasyIn.getInt(); } System.out.println(" ");
for (int i=0; i<4; i++) { System.out.print("Please Enter Amount For Customer 4's " + title[i] + "= "); Customer4[i] = EasyIn.getInt(); } System.out.println(" ");
//User Menu System.out.println(" "); System.out.println("Configuration Menu"); System.out.println("--------------------");
for (int i=0; i<6; i++) { System.out.println(ConfigMenu[i]); } System.out.println(" "); System.out.println(" ");
System.out.print("Please select an option from the above menu (A,B,C,D,E or F). = "); Choice = EasyIn.getChar();
if ((Choice == 'A') || (Choice == 'a')) { System.out.print("Please select a customer. (1,2,3 or 4) = "); Customer = EasyIn.getInt(); } } }
Please could you tell me where I am going wrong.
Patricia Shanahan - 12 Mar 2006 19:38 GMT >> I've written some suggestions for how to get started on programming >> assignments, at [quoted text clipped - 26 lines] > Then you fill in the first gap, compile it, test it, and when you are > happy with it you can continue to the next section. If you have any trouble thinking up the comments, forget about the computer for a while and go to pencil and paper.
Try to work out the procedures you would follow if you had to do the task you program is supposed to do. Squared paper is helpful, because it makes it easy to lay out arrays.
As you get comfortable with what you would do to carry out the task, write down each step. Take special note of places where you do the same thing more than once, and where there are alternative actions based e.g. on the user input. Imagine explaining how to do the task to someone who will do what they are told but will not show any initiative.
When you have a good set of notes, go back to the computer, enter them as comments, and go into testing and implementation.
I would suggest one small change in Mich's suggested procedure. Write, and run, each test before implementing the code it is supposed to test. The motivation for implementing the next thing should be a test failure. That way, you KNOW your test really does depend on the new code.
Patricia
IchBin - 12 Mar 2006 16:49 GMT > Below is what my assignment involves, could you basically point me in the > right direction to help me acomplish the task set but not give me the [quoted text clipped - 23 lines] > > You are to plan, design and impliment and test the mini banking system. Hi again, Andrew.
Based on your original code you may want to do this.
1 - Declare you customer arrays as instance arrays. That is, move your customer arrays up above your main method. This is so all methods can use them for all your A thru F processing. You will have to define them as 'static' (ex.):
private static int[] Customer1 Customer1 = new int[4];
2 - Add another letter for exiting your program. Like say "X" along with 'A' thru 'F'.
3 - Once you get all of the amounts for the customers accounts add a "while (!done)" loop.
4 - First method in loop will ask user what type of transaction 'A' thru 'X' they want to do.
5 - In the loop based on what option that was selected call a method to do that processing ('A' thru 'X').
If (option == 'A'){ processOptionAMethod(); }else if (option =='B'){ processOptionBMethod(); }... and so on until option 'X' that should exit your program.
You want to keep code separated into their own methods. For now keep all of the inputted information as instances objects (Like your customer arrays) so all methods can set or get them.
Thanks in Advance... IchBin, Pocono Lake, Pa, USA http://weconsultants.servebeer.com/JHackerAppManager __________________________________________________________________________
'If there is one, Knowledge is the "Fountain of Youth"' -William E. Taylor, Regular Guy (1952-)
Roedy Green - 12 Mar 2006 18:12 GMT >Below is what my assignment involves, could you basically point me in the >right direction to help me acomplish the task set but not give me the >acctual answer. see http://mindprod.com/jgloss/homework.html You must ask a specific question.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching.
Andrew.Bell - 12 Mar 2006 18:23 GMT haha, I definatly aint asking people to do my homework. I've spent over 1 full week now with my head in a book. I'm practically ready to comit suicide with this stuff, I aint no programmer and I'm here to get a foot in the door with what I need to acomplish with my assignment. Thanks anyway.
Rhino - 12 Mar 2006 19:08 GMT > haha, I definatly aint asking people to do my homework. I've spent over 1 > full week now with my head in a book. I'm practically ready to comit > suicide with this stuff, I aint no programmer and I'm here to get a foot > in the door with what I need to acomplish with my assignment. Thanks > anyway. You shouldn't take Roedy's post too personally. People frequently post here stating homework questions verbatim and ask us for the solutions. It's quite common for them to show no sign of effort at all: they don't post any code or ask any specific question other than saying (in effect) "Please post the complete answer in your reply." They appear to be literally expecting us to do their homework for them.
Several of us have noticed this phenomenon and have responded the same way as Roedy did. Quite frankly, most of us have no interest in being slaves to people who are too lazy to do their own homework. Some of us, like Roedy, have even written web-pages describing the best ways for such people to get help and laying out the circumstances under which most of us offer help.
Unfortunately, sometimes we misjudge the situation and assume that the poster has made no effort when they have actually tried very hard. I think that's what's happened here. This situation can be avoided if the original poster mentions how much effort he has made.
You shouldn't think that Roedy or the rest of us have any animosity to Java questions; many of us actually enjoy helping people with problems. Roedy in particular has built an extensive website with a lot of information about Java which he frequently cites in his replies. I doubt there's anyone on the newsgroup who has tried to answer as many questions as Roedy has.
We just don't like being taken advantage of by those who are trying to evade doing their own work. It's now obvious that you _have_ made a strong effort; we just didn't know it until now.
-- Rhino
Andrew.Bell - 12 Mar 2006 19:29 GMT Not a problem, my fault for posting such a complicated task, especially when I only have 4 months knowledge in this sh.t. If it wasnt for uni wanting me to do it for a piece of course work there is no chance in hell I would be taken up such a task to Java. Programming is horrible well for me it is anyway IMO. Thanks
Patricia Shanahan - 12 Mar 2006 20:02 GMT > Not a problem, my fault for posting such a complicated task, especially when > I only have 4 months knowledge in this sh.t. If it wasnt for uni wanting me > to do it for a piece of course work there is no chance in hell I would be > taken up such a task to Java. Programming is horrible well for me it is > anyway IMO. Thanks Programming is fun, Fun, FUN! The only way I can understand someone not enjoying programming is to remind myself that some people like eating fish, which I hate.
Seriously, pay particular attention to the notes on paper-and-pencil that I posted earlier. Going at it that way will let you separate as much as possible of the work of understanding the problem from the distasteful task of programming it. The programming will be easier if you have already done all the thinking about what the program should do.
Patricia
Roedy Green - 12 Mar 2006 19:40 GMT >haha, I definatly aint asking people to do my homework. I've spent over 1 >full week now with my head in a book. I'm practically ready to comit >suicide with this stuff, I aint no programmer and I'm here to get a foot in >the door with what I need to acomplish with my assignment. Thanks anywa There is a some serious help for your problem it at the link I gave you.
It also links to a an essay called "tackling" that will show you how to crack your problem into pieces that you can handle and how you can formulate questions people can answer.
Perhaps my most remarkable achievement in life was tutoring a kid from D to top mark in his grade, where the school made him redo the test under supervision they were so amazed. None of my students in computer science class at UBC ever failed.
I am not just putting you off.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching.
Andrew.Bell - 12 Mar 2006 19:54 GMT ok. the bit im stuck on is called 'nested statments' ...........
IF (user selects option A) write new menu of customers 1,2,3,4
[code] // customer choice System.out.println("Please select your option from above (A,B,C,D,E or F). "); choice = EasyIn.getChar();
if ((choice == 'A') || (choice == 'a')) { System.out.println("Please choose a customer 1,2,3 or 4"); customer = EasyIn.getInt();
if (customer == '1') { System.out.println("Customer 1"); }
else if(customer == '2') { System.out.println("Customer 2"); }
else if(customer == '3') { System.out.println("Customer 3");
}
else if(customer == '4') { System.out.println("Customer 4"); }//end of if option is A
else { System.out.println("Please select another user"); } [/code]
If I can get my head around what the code should be then my assignment will be easy but its this one bit thats killing me. what happenes is when I run the program ......
If (i select option A) new menu apears asking to select 1,2,3,4 when i press 1 or 2 or 3 or 4 output is "please select another user"
This is what is hurting me bad. its basically missing out the else if (customer = = '[no]') bit out and wont display the line of code for that selected customer.
Patricia Shanahan - 12 Mar 2006 20:09 GMT > ok. the bit im stuck on is called 'nested statments' ........... > [quoted text clipped - 14 lines] > System.out.println("Customer 1"); > } ...
As it appears in this message, the indentation of your code does not match the logical nesting. That may just be an artifact of newsgroup posting, but if your code is really indented this way it could be a source of confusion.
Do you have access to an automatic indenter? If not, consider getting one. See http://mindprod.com/jgloss/beautifier.html
Alternatively, but less reliably, go through your code making sure the indentation increases for every "{", and decreases for every "}". You may find it easier if you put every brace on a line by itself.
Patricia
Andrew.Bell - 12 Mar 2006 20:26 GMT its the way these newsgroups post things. the format is just basic text which when posting code its a nightmare.
You can see the code here.
http://www.zen62619.zen.co.uk/programming/java/coursework/MiniBank.java
>> ok. the bit im stuck on is called 'nested statments' ........... >> [quoted text clipped - 29 lines] > > Patricia Patricia Shanahan - 12 Mar 2006 20:40 GMT > its the way these newsgroups post things. the format is just basic text > which when posting code its a nightmare. > > You can see the code here. > > http://www.zen62619.zen.co.uk/programming/java/coursework/MiniBank.java I viewed the code with notepad, and the problem still seems to be there. Be VERY careful about the match between alignment and logical nesting. The symptoms you described earlier could be related to the nesting-alignment mismatch I'm seeing.
I've re-indented the critical piece of code, without changing anything logical. I hope this comes through OK, but as you say there can be formatting problems with newsgroup postings:
if ((choice == 'A') || (choice == 'a')) { System.out.println("Please choose a customer 1,2,3 or 4"); customer = EasyIn.getInt();
if (customer == '1') { System.out.println("Customer 1"); }
else if (customer == '2') { System.out.println("Customer 2"); }
else if (customer == '3') { System.out.println("Customer 3");
}
else if (customer == '4') { System.out.println("Customer 4"); }// end of if option is A
else { System.out.println("Please select another user"); } } }
Patricia
Patricia Shanahan - 12 Mar 2006 20:46 GMT >> its the way these newsgroups post things. the format is just basic >> text which when posting code its a nightmare. >> >> You can see the code here. >> >> http://www.zen62619.zen.co.uk/programming/java/coursework/MiniBank.java Also, is customer supposed to be char or int? There is a difference between the int literal 1 and the char literal '1'.
Patricia
Andrew.Bell - 12 Mar 2006 20:55 GMT In my code customer is ment to be INT and Choice is ment to be CHAR. When the user selects the first option in the menu (A) (CHAR) (choice) another menu can be seen for the user to select from (customer 1, Customer 2, customer 3 or customer 4) (INT) (customer)
Thanks Patricia going to check the code now. 'nope' problem is still occuring in my code it seems to not want to display the system.out.println("customer) after the INT customer has been selected. (1,2,3,4) ......
>>> its the way these newsgroups post things. the format is just basic text >>> which when posting code its a nightmare. [quoted text clipped - 7 lines] > > Patricia Patricia Shanahan - 12 Mar 2006 21:46 GMT > In my code customer is ment to be INT and Choice is ment to be CHAR. When > the user selects the first option in the menu (A) (CHAR) (choice) another [quoted text clipped - 5 lines] > the system.out.println("customer) after the INT customer has been selected. > (1,2,3,4) ...... I also have a handy page on how to debug: http://home.earthlink.net/~patricia_shanahan/debug/index.html
Patricia
Roedy Green - 12 Mar 2006 23:54 GMT >I viewed the code with notepad, and the problem still seems to be there. >Be VERY careful about the match between alignment and logical nesting. >The symptoms you described earlier could be related to the >nesting-alignment mismatch I'm seeing. There are many tools to do this for you called Beautifiers It the beautify button at least every 60 seconds when I am coding. Modern IDES have one built in.
See http://mindprod.com/jgloss/beautifier.html http://mindprod.com/jgloss/ide.html
I don't know how people code without one. They must waste a heck of a lot of keystrokes.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching.
Chris Smith - 13 Mar 2006 00:09 GMT > There are many tools to do this for you called Beautifiers It the > beautify button at least every 60 seconds when I am coding. Modern > IDES have one built in. Really? I use this only for code that's not already formatted, or when I need to fix something and I estimate that the time required to fix it by hand is less than the time to find and fix all the actually meaning formatting I've done in this file that's now gone because of the automatic formatter.
Not that such tools aren't useful... certainly they are, especially when, as is commonly the case with an IDE, the same formatting rules can be applied to auto-indents and code templates and other such features. If you run one every sixty seconds, though, then I wonder how you live without the ability to format your own code in intelligent ways.
 Signature www.designacourse.com The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer MindIQ Corporation
Roedy Green - 13 Mar 2006 00:25 GMT >Really? I use this only for code that's not already formatted, or when >I need to fix something and I estimate that the time required to fix it >by hand is less than the time to find and fix all the actually meaning >formatting I've done in this file that's now gone because of the >automatic formatter. The key is to configure your formatter to do thing exactly as you would do them by hand. Have a look at what Eclipse and IntelliJ formatters will do. You can get very close.
If you are not used to using a beautifier, just for fun count your ratio of keystrokes that are arrow and space to actual code characters. I think you will be shocked how high the ratio can be.
The IntelliJ and Eclipse also have reordering. I just insert methods and variables right beside where I am working, which is highly convenient for the moment, then later hit rearrange to pull them all to their proper positions. It saves a lot of jumping around in the file to find things.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching.
Andrew.Bell - 13 Mar 2006 00:52 GMT ok, ive done a main program so users can pick an option from a cofiguration menu and then select the customer. Is there anything wrong with this class file.
http://www.zen62619.zen.co.uk/programming/java/coursework/MiniBank.java
Please could you let me know how to let the user press esc at any time to close the program. Is this possible or is it too complicated for a user whos only been learning it for 4 months?
Cheers
Mitch - 13 Mar 2006 01:04 GMT > ok, ive done a main program so users can pick an option from a cofiguration > menu and then select the customer. Is there anything wrong with this class [quoted text clipped - 7 lines] > > Cheers Don't take this the wrong way but was 4 months a typo? After studying Java for 4 months you should be well passed this level of code. I only ask because if it is four months you really should be using this project from a more object oriented point of view, which though you haven't asked for here might be what your teacher / lecturer is after.
Patricia Shanahan - 13 Mar 2006 01:56 GMT >> ok, ive done a main program so users can pick an option from a >> cofiguration menu and then select the customer. Is there anything [quoted text clipped - 5 lines] >> to close the program. Is this possible or is it too complicated for a >> user whos only been learning it for 4 months? Rather than aiming to allow the user to press esc at any time, it might be easier, and sufficient, to add a menu item for exiting the application, and pick that up in the switch or whatever that you use to select among the various tasks.
>> Cheers > [quoted text clipped - 3 lines] > from a more object oriented point of view, which though you haven't > asked for here might be what your teacher / lecturer is after. The base message of the thread includes the assignment. It says "Each customer should be represented as an array with 4 elements (Each element of the array will represent one of their accounts)." and "Each customer aray should be an array of intergers." none of which sounds very O-O, or as though the writer of the assignment can spell.
Andrew - has the instructor discussed defining your own classes?
As far as the question about what is reasonable is concerned, I think that may depend on how intensive the course is, and the required background. I would certainly expect much more of a CS student who is spending a significant portion of their time learning Java.
Patricia
Mitch - 13 Mar 2006 02:12 GMT >>> ok, ive done a main program so users can pick an option from a >>> cofiguration menu and then select the customer. Is there anything [quoted text clipped - 24 lines] > customer aray should be an array of intergers." none of which sounds > very O-O, or as though the writer of the assignment can spell. Indeed. You can only assume it was copied from the assignment itself. And no it doesn't suggest any references to OO design.
> Andrew - has the instructor discussed defining your own classes? > [quoted text clipped - 4 lines] > > Patricia I think it would depend as well, but four months is a long time. Granted as a CS student myself (sort of) my view may be skewed but as a CS student this would probably be our 4th assignment. At that rate we are talking a month between assignments. I'm definitely not knocking him but it just seemed odd and wanted to make sure he wasn't missing a fundamental point to his task.
Plus you never know, stick the objects in there and you might get extra credit...
Chris Smith - 13 Mar 2006 05:17 GMT > I think it would depend as well, but four months is a long time. Granted > as a CS student myself (sort of) my view may be skewed but as a CS > student this would probably be our 4th assignment. At that rate we are > talking a month between assignments. I think it's a mistake to:
1. Assume that this is a CS major. Many colleges (IMO rightly) require some amount of programming ( a non-major course) for a wide range of engineering degrees.
2. Assume that there is ANY kind of consistency in CS education between colleges, much less between continents. I recently got involved (long story...) in a local community college that claims to teach computer science, and I can tell you it's thoroughly depressing what passes for teaching computer science there. (College name withheld to protect the guilty.)
 Signature Chris Smith
Andrew.Bell - 13 Mar 2006 19:12 GMT No, please may i tell you i only do this 2 days a week, i also work 3 days a week as a network technician and in the 2 days im at uni i also study my mcse and ccna and i do the java aspects aswell. give me credit guys come on please. 4 months to learn (SEM 1 CCNA, SEM 1 MCSE and Java Programiming ) and also work on top of this .................... credit ?
I have discussed my issues with a member of where I work and they have helped me a great deal to help me understand what is needed.. Cheers
IchBin - 13 Mar 2006 20:38 GMT > No, please may i tell you i only do this 2 days a week, i also work 3 days a > week as a network technician and in the 2 days im at uni i also study my [quoted text clipped - 4 lines] > I have discussed my issues with a member of where I work and they have > helped me a great deal to help me understand what is needed.. Cheers Andrew, you never heard me say any thing critical of you work. In fact I thought that I complimented you over in the comp.lang.java group. Just realize there will always going to be someone who has a big impressions of themselves. Just ignore them.
 Signature Thanks in Advance... IchBin, Pocono Lake, Pa, USA http://weconsultants.servebeer.com/JHackerAppManager __________________________________________________________________________
'If there is one, Knowledge is the "Fountain of Youth"' -William E. Taylor, Regular Guy (1952-)
Mitch - 13 Mar 2006 21:23 GMT >> No, please may i tell you i only do this 2 days a week, i also work 3 >> days a week as a network technician and in the 2 days im at uni i also [quoted text clipped - 10 lines] > realize there will always going to be someone who has a big impressions > of themselves. Just ignore them. I don't think anybody said anything critical of the work. I only made my initial comment to make sure that something wasn't getting missed.
I'm new here so let me say this now, and if I ever go back on it you can bitch at me all you like. I lurk here because I learn from the answers to other's questions. I also ask a few of my own. If you look at my questions you will see that I am hardly 'professional quality'. I have no foundation on which to stand to look down to people so I don't.
Andrew: I wasn't having a go. It was only after the 4 month category that I thought perhaps you were looking at it wrongly. In my head that's fair reason to be cautious: I imagine 90% of Java courses will have had you on more advanced stuff after 4 months but obviously some will fill in the extra 10. That isn't knocking you, obviously you have a hectic schedule as well, but hopefully you can see where I am coming from.
Anyway, glad you have it clearer in your head now.
Mitch.
Andrew.Bell - 13 Mar 2006 22:27 GMT nah, i never have mentioned about anyone bitching in this newsgroup, sometimes its good to bitch as I know where my weaknesses are. I've tried to do as this thread has said and I'm doing pretty well alough still alittle stuck in putting the correct code in the right places but I'll get there eventually just gunna take time. Iv'e spent well over 48 hours now designing the first bit of code, I scrapt the code I did earlier as I'm gettin few different ways to do it and its all confusin me. I've tried using Methods but I'm confused about them. Ive looked up on the net about different Methods and found very little pages. I think its partially to do with my lack of knowledge in programming. I have 5 weeks to hand it in now and this is very confusing.
Mitch - 13 Mar 2006 22:46 GMT > nah, i never have mentioned about anyone bitching in this newsgroup, > sometimes its good to bitch as I know where my weaknesses are. I've tried [quoted text clipped - 7 lines] > with my lack of knowledge in programming. I have 5 weeks to hand it in now > and this is very confusing. Are you given any notes? The web is great but only if you know what you are looking for.
Core Java 2 is superb book in my opinion, and if you don't mind second hand isn't too costly. Of course there are always libraries. (I'm talking in the traditional big building with books sense for once) ;)
The book I mentioned is here http://www.amazon.co.uk/exec/obidos/ASIN/0131482025/qid=1142285980/sr=2-1/ref=sr _2_3_1/026-9477017-8973241 UK or here USA http://www.amazon.com/gp/product/0131482025/qid=1142286119/sr=2-1/ref=pd_bbs_b_2 _1/002-0030086-1262459?s=books&v=glance&n=283155 and think it would really help if you think you'll ever use Java again. As far as serious programming goes I think Java is one of the easiest to learn, but only once you have grasped the fundamentals.
In the meantime have a go at something, then if you cant do it, have a go again, and then still if you can't post it here and I'm sure we will have a look.
Read back over the threads as well, there are some good posts about how to get started and some good links to other resources.
HTH
Mitch.
Andrew.Bell - 13 Mar 2006 22:58 GMT Managed to do my first method called from a private method using
nMenu();
Thats what I called the Method and it successfully brings the menu into play.
Anyway, yes i have read over and over books and threads. Ive got aomw book called 21 days learn java its a sams book. Looked through it and its head over heals but I'm gettin there. Just need to find a way of bringing this menu into play so a user can select options and data is outputed from the array created.
Oliver Wong - 16 Mar 2006 19:50 GMT > Ive got aomw book called 21 days learn java its a sams book. Is it by Laura Lemay and Charles L Perkins? Honestly, I don't think it's a very good book for learning Java. The book focuses too much on writing applets, and not enough on the concepts behind programming itself, and object oriented design.
- Oliver
Oliver Wong - 16 Mar 2006 18:35 GMT > I've tried using Methods but I'm confused about them. Ive looked up on > the net about different Methods and found very little pages. "method" is a word that has a special meaning in Java. If you try googling for something like "Java programming method", Google might give you pages about programming *methodologies*, which is something completely different.
To put a simply, a method is basically a bunch of statements group together, and given a name. In other programming languages, they're called "function", "subroutine", "procedure", etc.
Here's the source code for a file which defines a class called "Foo" which has a method called "bar".
<example> public class Foo { public static int bar() { int x; x = 5 + 3; return x; } } </example>
In case it isn't clear, here's the same code, but everything is stripped away except for the method:
<example> public static int bar() { int x; x = 5 + 3; return x; } </example>
If you haven't covered object oriented design or classes yet, just put "public static" before all your methods. Then, you have to specify the return type of the method, the name, and then a list of arguments that the method accepts (in this case, the list is empty; i.e. the method takes zero arguments).
You should find yourself a good introductory Java textbook if you're not familiar with methods, as they are pretty core to being able to write Java programs.
- Oliver
steve - 13 Mar 2006 23:09 GMT > No, please may i tell you i only do this 2 days a week, i also work 3 days a > week as a network technician and in the 2 days im at uni i also study my [quoted text clipped - 4 lines] > I have discussed my issues with a member of where I work and they have > helped me a great deal to help me understand what is needed.. Cheers as you are a student with network access, grab a copy of "amule", then in the search window do a global search for..
learning Java Java Examples in a nutshell Hardcore Java Java Cookbook
You will find all these texts available. , in PDF searchable format.
Steve
Andrew.Bell - 13 Mar 2006 23:34 GMT Yep, shall do i use limewire but you didn't no I typed that....... ;)
cheers Steve
Andrew.Bell - 12 Mar 2006 22:18 GMT OMFGGGGGGGGGGGGGGGGG
I am going to kill someone............. hahaha I'm so dumb I found my problem thanx guys for all ur help its very frustrating........ here was my problem...
Correct Version if (customer == 1) { System.out.println("Customer 1"); }
Wrong Version if (customer == '1' ) { System.out.println("Customer 1"); }
Spot the mistake ? ..... yes im really annoyed now, time to get a cuppa tea to calm me down ill continue with it later thanx all you guys ...
Patricia Shanahan - 12 Mar 2006 22:27 GMT > OMFGGGGGGGGGGGGGGGGG > [quoted text clipped - 16 lines] > > Excellent! That's why I asked whether customer was supposed to be an int or a char.
Patricia
Andrew.Bell - 12 Mar 2006 22:34 GMT damn im so happy, haha ok thats me sorted for user picking 'user menu A' now onto 'user menu B' :)
6 hours of trying to find that mistake is beond a joke. :) lesson learnt though ill bare in that in mind what mistake I did for future reference.....
if (andrew = = "stupid mistake") { System.out.println("Back to the drawing board") } else { System.out.printline("Congratulations! you found the mistake") }//end of stupid if }
I will be sitting reading the sites that has been mentioned in this thread see if i can spot any common things to use. thanks for the guidence.
Oliver Wong - 16 Mar 2006 19:52 GMT > damn im so happy, haha ok thats me sorted for user picking 'user menu A' > now onto 'user menu B' :) [quoted text clipped - 10 lines] > }//end of stupid if > } The tiniest difference can radically alter the behaviour of your program. That's why I'd like to point out you have an extra closing brace '}' in the code snippet above. Good luck ;)
- Oliver
steve - 13 Mar 2006 23:05 GMT > OMFGGGGGGGGGGGGGGGGG > > I am going to kill someone............. hahaha I'm so dumb I found my problem
> thanx guys for all ur help its very frustrating........ here was my problem... > [quoted text clipped - 10 lines] > Spot the mistake ? ..... yes im really annoyed now, time to get a cuppa tea > to calm me down ill continue with it later thanx all you guys ... what i do to specifically avoid this problem (not that i would ever code menu selections like this) would be:
if i meant a string, i would code it like this:
if customer.equals( new String ('1')){ System.out.println("Customer 1"); }
The advantage is that when your eye scans the code looking for errors, it is very hard to miss the ' it may take a bit longer to type the code, but nowhere near 6 hours.
Also be aware in some situations '==' may ACTUALLY FAIL, even though the 2 items being compared actually look the same.
Steve
Andrew.Bell - 13 Mar 2006 23:35 GMT How would you code menus ?
Would you use Methods?
steve - 14 Mar 2006 23:46 GMT > How would you code menus ? > > Would you use Methods? you need to destinguish what you mean by "menu's" Actually that may be my fault, there are the pulldown menus, and then there are user selection lists.
The way you are doing it is perfectly fine for the level you are working at, in that you get credits for , a working program.
As you have a significant workload from your course, keep it simple, then if later you really want to get into Java, then worry about it.
Steve
Oliver Wong - 16 Mar 2006 19:55 GMT > if i meant a string, i would code it like this: > > if customer.equals( new String ('1')){ > System.out.println("Customer 1"); > } Does this compile? I think you mean:
<code snippet> customer.equals(new String("1")) </code snippet>
(Note that I use the double-quote character, rather than the single-quote).
Anyway, you should probably instead write:
<code snippet> customer.equals("1") </code snippet>
This avoids an extraneous String creation.
- Oliver
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|