Re: Help -- New to Java




"Al" <doubletrouble_s@xxxxxxxxx> wrote...

I am taking a java class for the first time. The first HW was easy. I
am stuck on the 2nd. I know the logic, I can write it in C, but with
Java I am having problems and it is due tomorrow.

If you can write it in C, I don't really see the problem.

It should be pretty much the same in Java.

The small differences I can imagine from your "old practice" of C could be
the declaration/definition parts for arrays and methods.

int[] numbers = new int[10000];

....instantiates an array with 10000 numbers (all zero), which you can loop
through to give random values.

public static int double(int[] p) {

// Here you put in the logic to calculate the average

}

The main difference from C in this aspect is that you need to use the
keyword "static". Otherwise it becomes an "instance member" instead of a
"class member".

Is there any site where I can find small sample programs.
Appreciate any help. This is my HW prob.

http://www.google.com/search?q=Java+code+examples
http://www.google.com/search?q=Java+code+snippets

....and of course:

http://java.sun.com/docs/books/tutorial/getStarted/

....to begin with...

More specific examples for your assignment you can find through these pages:

- The class name should be StatFunctionsXXX where XXX is your name.

http://www.google.com/search?q=Java+defining+class+example

- Use an array defined in the main() function to store the numbers.

http://www.google.com/search?q=Java+array+example

- Use the java.lang.Math class

http://java.sun.com/javase/6/docs/api/java/lang/Math.html

- Write a static method to generate the numbers.
- For each type of calculation, use a separate static method
(function) returning an integer or double value.

http://www.google.com/search?q=Java+static+method+example

- Use java.util.JOptionPane to display all the results in one
single dialog.

http://java.sun.com/javase/6/docs/api/javax/swing/JOptionPane.html


/// Bjorn A


.



Relevant Pages

  • Setting up the Java 2 SDK 1.5.0 kit
    ... I'm trying to learn Java. ... I'm stuck at the setup phase. ... But when I come to javac the code I keep getting the following error. ... operable program or batch file. ...
    (comp.lang.java.help)
  • Re: java
    ... I need to create a website that can do the following in java, ... Well, I would say that your instructor provided pretty exact instructions, ... out the bit where you got stuck and give you a hint on how to get unstuck. ...
    (comp.programming)
  • Re: Help with numeric conversion
    ... >> public static int unsignedByteToInt{ ... > Bytes in java are always signed, which contradicts the name of the ... wolfgang$ cat test.java ...
    (comp.lang.java.help)
  • Re: avoid lot of try/catch blocks
    ... I don't know about the OP, but where I work a substantial portion of the Enterprise Java applications are running on Java 1.3, and that's been officially retired for a while. ... Oh, sure, their Windows desktops are all pretty much XP now, but the production databases in many organizations are just coming off Oracle 8. ... Risk management becomes the critical decision factor, and only when the risks of an old platform sufficiently overbalance the risks of change are these organizations willing to move. ... So the short answer to "what group are stuck on 1.4" is "most production systems, if they've progressed that far yet". ...
    (comp.lang.java.programmer)
  • Re: End of String
    ... public static int strlen(charbuffer) ... throws IllegalArgumentException { ... public static int strlen ... Remember that arrays in Java _also_ have the length attribute. ...
    (comp.lang.java.programmer)