Purchase Solution

Java Program using Two Arrays of Undefined Length in Runtime

Not what you're looking for?

Ask Custom Question

Write a program in Java which defines two unconstrained arrays of user defined length n, that contain n Random numbers each and which outputs the addition of pairs of elements. For example, given {1, 2, 3} and {4, 5, 6} the output would be {5, 7, 9}. Please use well commented code. The program must consist of at least 2 files.

Let's assume the user enters an array length of 5. The output would be:

arr1 arr2 sum
0 12 7 19
1 34 19 53
2 2 45 47
3 23 8 31
4 14 23 37

Purchase this Solution

Solution Summary

I have attached the program which creates two arrays A and B using method populateArray() whose size is determined by user input. A and B are populated using method populateArray() with random numbers of the given size n. Finally, the two arrays and their sum kept in another array C are displayed using method showArrays(). All of these methods are encapsulated in a class called Arrays . An instance of Arrays object in the main method of another class ArrayMain. Thus the program consists of two files Arrays.java and ArrayMain.java, both of which are included in the attached compressed file. Two compiled class files are also included.

Solution Preview

I have attached the program which creates two arrays A and B using method populateArray() whose size is determined by user input. A and B are populated using method ...

Purchase this Solution


Free BrainMass Quizzes
C++ Operators

This quiz tests a student's knowledge about C++ operators.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

C# variables and classes

This quiz contains questions about C# classes and variables.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Basic Networking Questions

This quiz consists of some basic networking questions.