aspose file tools*
The moose likes Java in General and the fly likes Review my Java program.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Review my Java program.." Watch "Review my Java program.." New topic
Author

Review my Java program..

dessa jones
Greenhorn

Joined: Jan 23, 2003
Posts: 1
My homework assignment is as is below and the program. Please let me know if this is what the instructor is asking for when he states "procedures" within the program. I'm alittle confused as to what he is asking. Do I need to add more, am I on target, or completely wrong. The program is also below..
Program: Create a java program that uses arrays.
you must create a procedure and enter data into this array in the procedure. you must create another procedure and display the date entered from inside the other procedure.
class ArrayOps
{
// . . . previous methods could go here
// add up all the elements in an array
int sumElements ( int[] nums )
{
int sum = 0;
for ( int j=0; j < nums.length; j++ )
sum += nums[j];
return sum;
}
}
class ArrayDemo
{
public static void main ( String[] args )
{
ArrayOps operate = new ArrayOps();
int[] ar1 = { -20, 19, 1, 5, -1, 27, 19, 5 } ;
System.out.println("The sum of elements is: " +
operate.sumElements( ar1 ) );
}
}
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Procedures? You can start by explaining to your prefessor that they are called methods in Java. :roll:


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Shashi Kanta
Ranch Hand

Joined: May 08, 2002
Posts: 89
Hi,
Procedure means method in Java. It is a function you write to carry out certain common task.
I think what he wants is something like this:

Hope your instructor is satisfied with your assigment !!
Shashi
p.s: by the way are you still studying in a school or college? just curious !!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Review my Java program..