Re: Help -- New to Java
- From: "Bjorn Abelli" <bjorn_abelli@xxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 26 Jul 2007 08:19:10 +0200
"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
.
- Follow-Ups:
- Re: Help -- New to Java
- From: Lew
- Re: Help -- New to Java
- References:
- Help -- New to Java
- From: Al
- Help -- New to Java
- Prev by Date: Re: Question for Roedy
- Next by Date: BufferedReader do not change output for new file
- Previous by thread: Re: Help -- New to Java
- Next by thread: Re: Help -- New to Java
- Index(es):
Relevant Pages
|