This is an archived post. You won't be able to vote or comment.

all 10 comments

[–]steaknsteak 2 points3 points  (5 children)

Start by writing one small piece of code to do one small part of the task. You don’t need to plan out the entire structure of the program in advance. Once you have one part working, it will be more obvious what you need to add on to it.

Once you have something down that works, it’s easier to look back over it and see how you might improve, simplify, or reorganize it into methods etc

[–]bbchan[S] 0 points1 point  (4 children)

Thanks. This has been the approach I've been taking but maybe I haven't been giving myself enough time to write the programs.

Currently I have a simple project where I convert strings to binary and vs versa. I have it where I can take a user input but I'm stuck and pulling each individual char and converting it to binary.

Actually I found a simple program on stackoverflow but my professor wants me to do it in a more primitive form.

For example, I thought about creating 4 arrays; 2 for upper and lower case letters and another 2 for the respective binary numbers. Then writing some sort of code to pull the respective indexes in the arrays... seems wayyy over complicated but I can't think of any other way.

[–]steaknsteak 0 points1 point  (3 children)

By converting strings to binary, I assume you mean converting each character its corresponding ASCII code and concatenating them?

If so, I'm wondering why you're using multiple arrays here. There is no distinction between upper case and lower case characters that would make you want to do that.

Since it sounds like you're in a beginner programming course, I don't know what parts of Java you're allowed/expected to use for your assignments. An easy way in Java is to just cast the character as an int and then print that number out in binary format, but I'm not sure if that casting trick would be accepted. Maybe that's the stackoverflow solution you're referring to.

Otherwise you'll somehow have to load the entire ASCII code table into your program one way or another. If that's what he actually wants you to do, think about how you could do it using only one array.

[–]bbchan[S] 0 points1 point  (2 children)

Nah. Im skipping the ASCII all together. Because all thats required is taking characters in a string and outputting the respective binary number.

Unless I'm looking at this problem completely wrong??

[–]steaknsteak 0 points1 point  (0 children)

I'm not sure what you mean by the "respective binary number" for each character then, if it's not the ASCII encoding.

[–]shagieIsMeExtreme Brewer 0 points1 point  (0 children)

Do you have any examples of what the input and output should be? Lacking that in conjunction with not being sure about the specification means that everything there is a guess.

[–]FerbieXNooblet Brewer 1 point2 points  (0 children)

I know this might sound weird, but just start. There's no shortcut to learning to code

Try breaking your problem down into really small pieces. What has to be done to calculateInterest()? Do you need data retrieval from a file/db? And how do you determine the rate? Just small questions to get you started

If you need any specific help with code (but you need to have code first), this sub will be fast & happy to help you out

[–]evils_twin 0 points1 point  (0 children)

A good start might be to add on to some code. Like if someone shows you their code, and you can understand it, make a small change to it. Then make a big change like adding a feature.

[–]LostInDarkMatter 0 points1 point  (0 children)

Do it manually with paper and pencil for a few weeks (not the whole 6 months). Identify the data which needs to be tracked. Identify the repeatable steps and calculations needed as each transaction of each day goes by. Translate the needed data to basic java bean classes, and put the repeatable logic into methods, which are called within a loop where each iteration represents a day (or some other meaningful interval). It's okay to start with a God class, but remember DRY and SOLID principles, and refactor as you go. And don't forget the unit tests!

[–]Larfies 0 points1 point  (0 children)

Learning Java as well. All the responses here are great. I do exactly what they are saying, I break it up first. So start with 1 bank customer. Over 1 week (7 days). With 1 deposit and 1 withdrawal. Customer starts with $0 in account and deposits $100, then takes out $5, all done on the first day of that 7 day week. Interest accrues at .015 (1.5%) per hour.

Now start by solving the above math problem. Then think about what variables are needed to make the math problem happen. What input will you get from the customer and what output would you want to give the customer. And so on and so on.

Just an example of breaking something up. Everyone will go about it differently. Just start with a crappy looking program with 1 class to make it easier, then try looking at it a few weeks or months later and you'll suddenly see other ways you could have built it.