Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Programming

 
Jay Jeong
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Im in AP Computer Science, and I am in serious trouble. I cant drop out because it's an AP class, and not only that, my teacher cant teach, nor can I afford a tutor. I have this assignment I have to do, and its called random numbers. Its where the scanner checks to see if certain numbers are in a given DAT.file (file with a list of 100 random numbers). Where do I begin? how would I start this? please, someone help
 
Ralph Cook
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think this forum is a great place for "How do I do this (general) task" type questions. Keep in mind no one here knows what you've covered so far, or what tools you have available, or what your previous knowledge is. Also, the effort involved in trying to replace whatever text and lectures you've had so far, even if we knew what those were, is beyond what most of us are willing to do under the circumstances.

In my experience, AP classes usually have students in them who already know something about their subject. I would imagine this is particularly true of computer classes involving programming. I suggest you find another student willing to give you pointers about how to get started.

If you try something and don't understand what an error or problem is, this forum is a good place to get answers to questions like that.

rc
 
Clivant Yeo
Ranch Hand
Posts: 124
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume that you should know how to program with Java and that you know how to read APIs (application programming interface).

Check out the java.util.Scanner class at http://download.oracle.com/javase/1,5,0/docs/api/java/util/Scanner.html

This should help you understand how to read the numbers from a file.


 
Vyas Sanzgiri
Ranch Hand
Posts: 686
Chrome Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch Jay Jeong!

All the best with you assignment.
 
Campbell Ritchie
Sheriff
Posts: 48910
58
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome again
You should write down on a sheet of paper what you want to do. Tell yourself exactly how to do it. It should be really simple. Instructions like thisare a start, but should be made even simpler. Once you have got the instructions really simple, you will know what code to write.

This is called the pseudo-code approach.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jay Jeong wrote:Hi, Im in AP Computer Science, and I am in serious trouble. I cant drop out because it's an AP class, and not only that, my teacher cant teach, nor can I afford a tutor.


It's unfortunate that you are in such dire straits, but this site is not intended to help with time management problems or financial problems. Bringing those up only distracts from the problem that we can help with--the technical Java problem.

Where do I begin? how would I start this?


http://home.earthlink.net/~patricia_shanahan/beginner.html
 
Jay Jeong
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not asking for financial assistance, Im simply asking how I should do certain programs. Im asking if there are any websites that can actually EXPLAIN how I can do my assignments. I thought this was a site that teaches me how to, but I guess I was wrong
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jay Jeong wrote:I'm not asking for financial assistance


I realize that. I simply pointed out that mentioning your finances is not at all relevant to the problem at hand, and is a distraction from discussion of your Java problem.

Im simply asking how I should do certain programs. Im asking if there are any websites that can actually EXPLAIN how I can do my assignments.


That's what your class is for. And the page I linked provides some good advice too. Did you read it? Did you try following that advice? How far did you get? Where did you get stuck?

I thought this was a site that teaches me how to, but I guess I was wrong


If you thought this site was meant to teach you the same way your class is meant to, then, yes, you were mistaken. If, on the other hand, you're willing to ShowSomeEffort, take your best stab, and ask a more specific question than "How do I write program X?" remembering, of course, to TellTheDetails, then you will find people are happy to nudge you in the right direction to help you get over the hump.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12122
30
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jay Jeong wrote:the scanner checks to see if certain numbers are in a given DAT.file (file with a list of 100 random numbers). Where do I begin? how would I start this? please, someone help

You need to start by breaking the problem down into the different components. you do this by writing down the steps and refining them over and over and over - you don't even touch a computer until you've spent a few hours with paper and pencil.

A few questions come to mind:
Where do these "certain numbers" come from?
Will you get them all at once, or one at a time?
Do you want to check them all at once, or one at a time?
What is the format of the data file?
What should your interface look like - can it be a command line, or do you need a GUI?

At the very least, you need three parts:

  • getting the 'certain numbers'
  • reading the data file
  • comparing items from one list to another


  • Note that I wrote item 3 in a very generic way. It doesn't matter WHERE those two lists come from. I should write my code in such a way that if I have two lists (one of those lists may only contain a single number), I can see if the elements in list 'A' are in list 'B'. This allows me to change my program later in case my prof says 'instead of reading the numbers from a file, you need to read them from a database'. If he does that, I only need to change the part of my program that reads the data, as the comparison part is not tightly coupled to how i read the data.

    So those are some tips on developing your program. But the actual answer to the question of "Where do I begin" is "download and install the JDK, and get it working". Then write a simple "Hello, world" program, compile it, and run it.




     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic