Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA Programming Inside class ArrSum, write a standalone function/procedure called sum with the following header: public static int sum(int[] a) The method sum takes an

JAVA Programming

Inside class ArrSum, write a standalone function/procedure called sum with the following header:

public static int sum(int[] a)

The method sum takes an integer array as an argument, and returns the sum of all elements back to the caller.

Write appropriate specifications (precondition, postcondition, and frame properties using assignable/modifies) for sum that describe the behavior of sum to all potential clients. Make sure to also implement sum.

Write a driver class TestSum with at least 3 different calls to sum.

I wrote this, but my jvm gives me an error, if you can please fix it and do what the question asking please,

//ArrSum.java

public class ArrSum {

public static int sum (int[] a) {

//Precondition: sum to be a int array as an argument

//Modifies: a

//Postcondition: sum of all the integers

System.out.println("ArrSum Class");

a = 10;

return a;

}

//TestSum.java

class TestSum {

public static void main(String [] args){

//ArrSum ArrObject = new Arrsum();

//ArrObject.sum(x);

//System.out.println(ArrObject);

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David J. Auer David M. Kroenke

13th Edition

B01366W6DS, 978-0133058352

More Books

Students also viewed these Databases questions