Home Tutorialhelp Comment need programme of following java 2 array

 
 

Comment

rajesh jasani
need programme of following java 2 array,
April 22, 2009 at 10:04 PM

java 2 array
Write an application to test utilize arrays in a variety of ways –
• you will be calling all of the methods you write from the main,
• so remember to make them static

Part 1
1A) In the main: Declare and create 2 arrays called nums1 and nums2
to store 15 integers
1B) Declare a third array called nums3 and assign to it 15 values of your choice
(from 1 to 30 – BUT NOT in sorted order ), for example {25,12,6,2,30……}

2A.Write a method called initArray to initialize an array of int to values from
0 to 14 using a loop.
2B.Pass in the nums1 array as a parameter.

3. Write a method called displayArray to display all numbers in an array of int
on one line in this format:
0 1 2 3 4 and so on. Pass in the nums1array as a parameter.

4. In the main: In the main method, call the initArray method passing in
nums1(see//4A to the right). Print an appropriate message(//4B) before calling
the display array(//4C) , so that you r results look like this:
The nums1 array after initializing:
0 1 2 3 4 and so on
The nums3 array after initializing:
25 12 6 2 30 and so on

5. Write a method called genRandom which takes the array nums2 as a parameter and fills it with random numbers between 1 and 100. in a ‘for’ loop, assign this stmt to each element in the array (int)(Math.random()*99)+1;

6. In the main: add a call to the genRandom methods passing in nums2 followed by an appropriate message explaining what the output will be and then call the displayArray method so your output looks like this:
The nums2 array after initializing:
17 4 12 (random numbers – different each time) and so on

7. Write a method called sumNumbers which takes the nums3 array as a parameter. It sums all numbers in the array and returns the sum as the value of the method. (check your sum by adding all the numbers you put in nums3)

8. In the main, add a call to the sumNumbers method, then Print a message telling what the output is followed by the results . For example:
The following is the sum of all numbers in the nums3 array (REMEMBER: when a method returns a value, you need to supply a variable to receive the answer in the calling statement. – Print the sum returned)


9. Write a method called underTen which takes the array nums1 as a parameter. It sums all numbers that have a value less than 10 in the array and returns the sum as the value of the method.

10. In the main: add a call to the underTen method, then Print a message telling what the output is followed by the results . For example:
The following is the sum of all numbers in the nums1 array that are less than 10


11. Write a method called smallest which takes the array nums3 as a parameter. It finds the smallest of the number in the array and returns it as the value of the method.

12. In the main: first call the displayArray method so your output looks like this:
The nums3 array after initializing:
10 5 15 (these should be the numbers you assigned in the create and initialize declaration) and so on

Now, add a call to the smallest method passing in nums3 as a parameter, then Print a message telling what the output is followed by the results . For example:
The smallest number in the nums3 array is


13. Write a method called largestIndex which takes the array nums2 as a parameter. It finds the largest of the numbers in the array and returns it’s index as the value of the method.

14. In the main: call the largest method, then Print a message telling what the output is followed by the results . For example:
The index of the largest number in the nums2 array is


15. Write a method called search which takes the array nums3 as a parameter and a random number you want to search for. (just pick one out of your array and pass it in as the second parameter) It finds the FIRST instance of that number and returns its index as the value of the method. If it does not find your random number, it returns a -1

16. In the main: call the search method, then Print a message telling what the output is followed by the results . Use a conditional to print either of these statements: For example:
The random number 6 was found at location 2 OR
The random number 6 was NOT found

17. Write a method called addToOverTwenty which takes the array nums3 as a parameter. It adds 1 to all numbers that have a value greater than 20 in the array . It has no return value.

18. In the main: add a call to the addToOverT wenty method, then Print a message telling what the output is followed by the results of calling the displayArray method. For example:
The nums3 array after adding 1 to all numbers greater than 20 is
10 6 15 and so on (check with the values you assigned to nums3)

19. In the main: Use the Arrays class’s static methods sort and binarySearch to complete the following:
a. Sort nums3 in ascending order
b. Do a binary search on nums3 for a searchNumber you choose
i. Output the number and its index which is returned if found
ii. If not found, binarySearch returns a negative number so output a not found message
c. The Arrays class is in the folder java.util.*; //so add the new import statement!


View All Comments | View Tutorial
Advertisement
Related Tutorial and Articles
Tools For Java Technology

Introduction to java arrays
of Arrays in Java Programming language. You will learn how the Array class... Introduction to java arrays   ... arrays. To meet this feature java has provided an Array class which abstracts 

Java Tips and Examples

Introduction to java arrays
Introduction to java arrays     ... in Java Programming language. You will learn how the Array class in java  helps.... Structure of Arrays Now lets study the structure of Arrays in java. Array 

Java Tips and Examples

Introduction to Java Arrays
Introduction to Java Arrays     ... in Java Programming language. You will learn how the Array class in java  helps.... Structure of Arrays Now lets study the structure of Arrays in java. Array 

Java Beginners

Arrays
Arrays   Hi I need help with the following exercises. Exercise 1: Write a Java application in which the user is prompted for the total number... of all the values as well. Exercise 2: Write a Java application in which you 

Java Tips and Examples

Introduction to Java Arrays
Introduction to Java Arrays     ... in Java Programming language. You will learn how the Array class in java .... To meet this feature java has provided an Array class which abstracts the array 

Java Beginners

arrays part 2 - Java Beginners
arrays part 2  Question 2: Useful Array Algorithms and Operations (5...: ? A static method search() that: o Has a parameter of integer array and another integer value o Searches the integer value in the array, and o Returns the element 

Java Beginners

java programme
java programme   1.....programme for reading 10 values for 10 variables using scanner class 2....declares all types of primitive data inside main method 

Java Beginners

java programme
java programme   i have to write a java programe that calculates the average of 10 students in Test 1 ,Test 2 and Test 3....Values of the marks in all the test for a student should be hardcore.Ialso have to tell the maixmum 

Java Interview Questions

Arrays
Implement Java code which takes 2 dimensional integer array as input and prints out heaviest island  Implement Java code which takes 2 dimensional integer array as input and prints out heaviest island 

Java Beginners

programme - Java Beginners
programme  java programme to implement stack operation?use stack... visit the following link to get the stack implementation: http://www.roseindia.net/java/example/java/util/StackImplement.shtml Use following code 

Java Interview Questions

JAVA programme - Java Interview Questions
JAVA programme  Perpare a class "package_example" following the basic functionality of "string" type in JAVA.Use of dynamic character arrays for such class is encouraged.Following is expected from the programme: a.Use of 3 

JDBC Questions

JAVA programme - JDBC
JAVA programme  Prepare a class ?String_Example? following the basic functionality of ?String ?type of JAVA. Use of dynamic character arrays for such class is encouraged. Following is expected from the completed Program 

Java Beginners

java arrays
java arrays  Suppose that you are required to store information about... and a StudentApplication class with a main method that keeps an array of student records, displays the following menu and allows a user to enter a value in the range 1 to 5: 1 

Java Beginners

arrays
arrays  using arrays in methods   Java use arrays... Array Elements: "); int array[]=new int[5]; for(int i=0;i<array.length;i++){ array[i]=input.nextInt 

Java Beginners

java arrays
java arrays  how do you write the code for multipliying 2 double arrays to be in a 3rd double array? here is my code: package employeepay... A reference to an array of doubles. */ public static double[] getArray 

Java Beginners

Arrays
Arrays  Write a program in java(BlueJ) to store the numbers in single dimensional array(S.D.A)into another S.D.A in reverse order of the location 

Java Beginners

Arrays in java
Arrays in java  what is param array in java 

Swing AWT

need a java program for the following
need a java program for the following  Write a java program with three horizontal sliders. Name the sliders, the first one as red, the second one as green and the third one as blue. You design the program such that on varying 

Java Beginners

arrays
arrays  public class Country{ string countryName; string location; int population; double area; } a.write a java statement to create an array of 10 country objects called mycountry using the Country class. b.Assuming 

Java Tips and Examples

Arrays -- Multi-dimensional
] | | | +-----+-----+-----+-----+ +-----+ In Java two-dimensional arrays are implemented is a one-dimensional array... Java NotesArrays -- Multi-dimensional All arrays in Java are really linear... from these, and Java has features in the language to help you do 

Java Interview Questions

arrays - Java Interview Questions
arrays  1)write a program that take integer array as input and find the second largest number in array?(Array values taken from keyboard)? 2)Given... a program that take arrays A & B as input and find missing element in B array 

Java Beginners

Java programme
Java programme  Write a program to get student grade for 3 different subjects, and display the CGPA for them 

Java Beginners

arrays - Java Beginners
]; int num; Write Java statements that do the following: a. Call the method... and Alist, respectively. another problem.,, 2.)Suppose list is an array of five components of the type int.What is stored in list after the following Java code 

Java Beginners

lucky no programme - Java Beginners
lucky no programme   Sir , with due respect , iam a beginner level programmer i need some hint in making lucky no programmme . So please send me lucky no programmme on my mail 

Programming Tutorials

Arrays in java
Arrays in java Arrays are the data structure of java , we use array where we need contiguous memory allocation. Array stores same type of data structure... an array of length 5.  For more details click here : Java Array Tutorial 

Java Tips and Examples

Arrays
arrays Java 2 added anonymous arrays, which allow you to create a new array... Java NotesArrays Java arrays are similar to ideas in mathematics An array... by specifying a subscript or index. "Array" in Java means approximately the same 

Java Beginners

java arrays
java arrays  can i know how can we intilize the three dimentional arrays in java? and how can we assign thae values to that array 

Java Tips and Examples

Java Arrays Tutorial
download. Introduction to Java Arrays In this section you will be introduced to the concept of Arrays in Java Programming language. You... of Java Arrays Now lets study the structure of Arrays in java. Array 

Java Beginners

java arrays
java arrays  i need a java program to store student details like id,name,addr,marks,average,total..using arrays..input data using scanner class and by using class, object and constructor 

Java Beginners

how to compare 2 arrays using java?
how to compare 2 arrays using java?  hi can anyone give me the information regarding comparision of arrays.   Java Compare Arrays 

Java Interview Questions

Arrays - Java Interview Questions
Arrays  1)write a program that take integer array as input and find the second largest number in array?(Array values taken from keyboard)? 2)Given... a program that take arrays A & B as input and find missing element in B array 

Java Beginners

Java with Arrays
Java with Arrays  I was given the assignment to create two parallel arrays; both of size 50 (declares 50 as a constant) One is an array of strings and hold names, While the other is an array of numbers (int or double) to hold 

Programming Tutorials

Introduction
; Introduction Applet is java program that can be embedded into HTML pages. Java applets runs on the java enables web browsers such as mozila and internet explorer... written in java programming language and embedded within HTML page. It run 

Java Beginners

java 2 d array program
java 2 d array program  write a program 2-d matrix addition through user's input?  Hi Friend, Try the following code: import...[][] A = new int[2][2]; int[][] B = new int[2][2]; int[][] C = new int[2][2 

Programming Tutorials

An Overview of Java      Java is a programming language      Java is Object Oriented Programming
will be introduced to the concept of Arrays in Java Programming language. You...; Java as a programming language Java is an Object oriented application programming language developed by Sun Microsystems. Java is a very 

Applet Questions

applet images sleeping programme - Applet
[] x2; int[] y2; int dx1 = 2 + (int)( 3 * Math.random()); int dy1 = 2 + (int)( 3 * Math.random()); int dx2 = 2 + (int)( 3 * Math.random()); int dy2 = 2 + (int)( 3 * Math.random()); static int first = 0; final 

Java Beginners

java 2d arrays
java 2d arrays  Create a program that will: a) Create the array and populate it with the given values. 9, 8 2, 17 49, 4 13, 119 2, 19 11, 47.... and if i do it manualy it is wrong. public class Arrays { public static void main 

Java Beginners

guys,, need help,, in java programing,, arrays
guys,, need help,, in java programing,, arrays  create a program where you will input 10 numbers and arrange it in ascending way using arrays 

Java Beginners

Java programme - Java Beginners
Java programme  Develop a multi-threaded GUI application using java application 

Java-Tutorials

Introduction
Java as an Object Oriented Language       Introduction:  In this section, we.... But in case of java,  it is a fully Object Oriented language because 

Java Tips and Examples

Arrays -- Intermediate
Java NotesArrays -- Intermediate Anonymous arrays Java 2 added anonymous arrays, which allow you to create a new array of values anywhere... another array. Dynamic allocation Because arrays are allocated dynamically 

Java Beginners

arrays in java - Java Beginners
arrays in java  Hi All, I have two arrays. in this two array some name are same. I want to merge those arrays into single. But while merging I want to delete duplicate entries. How merge those arrays. Thanks, mln15584 

General

Introduction to the JSP Java Server Pages
source code. Introduction to JSP Java Server Pages or JSP... applications.   JSP Tutorials - Introducing Java Server Pages Technology JavaServer Pages (JSP) technology is the Java platform 

Java Interview Questions

arrays - Java Interview Questions
arrays  will un store objects in arrays  Hi friend, Yes u will store Objects in array. Integer[] IntegerArray = { new Integer(1), new Integer(2), new Integer(3 

Java Beginners

Arrays - Java Beginners
would like to enter. Then create a corresponding array and prompt the user... the content of the array to a file called ?data.txt? using a while-loop. I...) with the following methods: promptUser // prompts user for int input loadArray // fills 

Java Beginners

arrays - Java Beginners
dependentOf, whose type is Employee 2. It should have a constructor... a property called dependents to Employee that is an array of Dependent objects, and instantiate a five-element array * while this isn't the best practice 

Java Beginners

arrays - Java Beginners
in an array, and o Returns the array   ? Include a static method that: o Has a parameter of integer array o Finds the largest value in the array... of integer array o Finds the smallest value in the array, and o Returns the smallest 

Java Beginners

arrays
class ,create an array {4,34,5,3,6,8,1} remove 3 and 5th element and shift following left and adding zero at the end of array... another one is to search... the given list of array. public class JavaRemoveArrayElementExample 

Java Beginners

please solve the programme
please solve the programme  Develop a java program to find the roots of a quadratic equation ax2+bx+c=0, with the following specification :- Class name :- Quad Data members float a,b,c,d, with a,b,c are the co-efficient 

Java Beginners

Write a java program that prints out the following menu???
Write a java program that prints out the following menu???  Write a java program that prints out the following menu. Auser can interact with the menu... another input. Menu : 1. Find min between 3 numbers using (Math.min). 2. Get 

Struts 2 Tutorials

Introduction To Application
in the examination he need to login on the website then, he / she can select the language... test paper of that particular language. For example- if he selects java the he can only see the java language test paper. After submitting the test paper he 

Java Beginners

Arrays - Java Beginners
Arrays  I need to ask you for one more help with this. pLs Write a program called ThreeArrayLists.java that declares three arrayLists referenced..., 3, 5.4, 2.9 4.8.   Hi Friend, Try the following code: import 

Java Beginners

Java using arrays - Java Beginners
Java using arrays  Write a program to input a possibly integer n(n<=10);followed by n real values into an array a of size n and the program must perform the following: Display back the values input Sort the values 

Date Calendar

Java programme - Date Calendar
Java programme  Can you provide me the coding for Date class provided by java util package 

Java Beginners

menu driven programme
menu driven programme   calculate the area of circle, square, rectangle in menu driven programme in java 

Java Server Faces Questions

java programme - Java Server Faces Questions
java programme  Write a complete program, which prints all Fibonacci numbers that are less than 1600.  Hi Friend, Try the following code: public class FibonnaciSeries { public static void main(String[] args 

Java Tips and Examples

Arrays -- Examples
Java NotesArrays -- Examples This applet shows a number of methods that use arrays. The source code for the methods is also given below. This applet will not display correctly unless your browser supports Java 1.2. Sort 

General

Converting java arrays into list
Arrays can be converted by the asList() method of the Arrays class. asList() It converts the object array into the fixed sized list Example...);         System.out.println(list.size());         System.out.println(list.get(2 

Java Beginners

Problem on JAVA Programme
Problem on JAVA Programme  public class AA { int add(int i) { int y = i; y += 20; if (y <= 100){ y +=30;add(y);} System.out.println("Final Value of y : " + y); return y; } public static void main 

Java Tips and Examples

Structure of Java Arrays
Structure of Java Arrays       Now lets study the structure of Arrays in java. Array is the most... type. Moreover, arrays are always of fixed length i.e. the length of an array 

Development process Questions

Need the Following MobileApplication Related Code
Need the Following MobileApplication Related Code  Hi, I need java coding for the following requirements in Collections.. Mobile Subscriber name...: and one Daemon Thread class need's to run while doing the above operations and if you 

Java Beginners

reverse arrays in java
reverse arrays in java  how do i make a code that can be used to reverse the elements of an array in two dimension such that the last element of an array becomes the first element of the array and the first element of an array 

Java Beginners

merge sorting in arrays - Java Beginners
merge sorting in arrays  Write a program to insert string or characters to an array and apply merge sorting on this array  Hi Friend, Please visit the following link: http://www.roseindia.net/java/beginners 

General

Introduction to Java
Introduction to Java       This section introduces you the Java programming language. These days Java... the origin of Web.   Java as an Internet Language Java 

Java Interview Questions

arrays program - Java Interview Questions
arrays program  how to write our own array program to find out n'th highest and n'th least i want source code plz replyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy  Hi Friend, Try the following 

Java Beginners

reverse arrays in java
reverse arrays in java  how do i write a program in array of size n*m where both n and m are greater than 20 such that the 1st element of an array becomes the last and vice verse 

Java Beginners

intersection of two java arrays
intersection of two java arrays  I am trying to figure out how to compare two arrays and get the intersection and put this into a third array of the correct size. I know how to copy the two arrays into the third array but am 

Java Beginners

Need help - Java Beginners
Need help   To Write a Java program that asks the users to enter a m... array; - Method 2 accepts the jth column of the array as its argument, and returns..., respectively. The program stores this matrix into a two dimensional m*n array 

Java Tips and Examples

Java - Array in Java
Array Example - Array in Java     ... language. By definition, array is the static memory allocation. It allocates... of arrays are used in any programming language such as: one - dimensional, two 

Java Beginners

arrays help - Java Beginners
arrays help  Write a program that sorts values. ? The program includes readIntegers() that o reads the user inputs o stores them in an array, and o returns the array   ? The program includes easySort() that o sorts 

General

Java Arrays Tutorials
(). Browse the following code to Learn Java Arrays in detail...The java.util.Arrays class helps the programmers to manipulating the arrays. It provides the methods to easily manipulate the arrays. Methods provided 

Java Beginners

java array
java array  write a java method that takes an array of float values... are distinct)   Hi Friend, Try the following code: import java.util.*; class...)){ System.out.println("There are duplicate elements."); Float array 

General

Java Language
will be introduced to the concept of Arrays in Java Programming language. You will learn how... Java Language       Java Comments To comprehend any programming language 

General

Introduction to Collection Algorithms
Introduction to Collection Algorithms       Algorithms: The Collections and Arrays classes.... The  Java platform provides great majority of the algorithms to perform 

Java Beginners

reverse two dimensional arrays in java
reverse two dimensional arrays in java  reverse array elements in two dimensional array such that the last element becomes the first 

Struts Examples

Detailed introduction to Struts 2 Architecture
Detailed introduction to Struts 2 Architecture   ...;  Following diagram shows the high level architecture of Struts 2 Framework:   Detailed Architecture of Struts 2 Framework Following diagram shows 

Java Beginners

Java Method with arrays
Java Method with arrays  My assignment is to write a java method, smallestIndex, that takes as its parameters an int array and its size, and returns the index of the (first occurrence of the) smallest element in the array. Also 

Java-Tutorials

Introduction to Java
Java is an open source object oriented programming language... features it provide to them over other languages. Java is a simple language... messaging, chat service, solving some complex calculation, etc. Java 2 Enterprise 

Hibernate-Tutorials

Introduction To Hibernate Query Language (HQL)
Introduction To Hibernate Query Language (HQL) In this tutorial you will learn about Hibernate Query Language. HQL is an abbreviation of Hibernate Query Language. It is a powerful query language, inspired by SQL that the Hibernate uses 

Java Tips and Examples

Two-dimensional arrays
; Two-dimensional arrays are defined as "an array of arrays". Since an array type is a first-class Java type, we can have an array of ints... of arrays of  ints". Such an array is said to be a two-dimensional array.  

Java Beginners

Java Programming Need Help ASAP
Java Programming Need Help ASAP  You are required to develop... class that creates an array of Students and handles it. You will need... of the students stored in the array o you will need a method to update all 

Java Beginners

array
array  array memory allocation is dynamic or static in java   Java Arrays have dynamic memory allocation 

Java Beginners

Arrays - Java Beginners
Arrays  I have created a multidimensional array(ten by ten number square) using java and I would like to separate the coumns using the pipe symbol...://www.roseindia.net/java 

Java Beginners

GUI 2 - Java Beginners
and C++.  Hi You need not worry of where to go and learn about java...; Hi You need not worry of where to go and learn about java..Jus search...GUI 2  How can I modify this code? Please give me a GUI 

Java Beginners

array 1 - Java Beginners
array 1  WAP to input values in 2 arrays and merge them to array M.  Hi Friend, Try the following code: import java.util.*; class...; for (int[] array : arr) { arrSize += array.length; } int 

General

Iterating java arrays
Iterating java Arrays arrays can be iterated by the for, for each loop. array elements can be added to the list and then it can be iterated by the iterator() method. Example 1 public class 

Java Beginners

array problem java - Java Beginners
array problem java  PLS HELP ME NOW I NEED YOU RESPONSE IMMDEATLETLY...]; int num; Write Java statements that do the following: a. Call the method..., respectively. another problem.,, 2.)Suppose list is an array of five 

Struts Examples

Introduction to Struts 2
, JSP API 2.0 and Java 5.  Video Tutorial - Introduction to Struts 2...Introduction to Struts 2       This section provides you a quick introduction to Struts 2 framework 

Java Beginners

java; arrays - Java Beginners
java arrays example  How can you create a program, by using arrays and the output would be X. by using char or string.Thank you 

Java Beginners

Arrays - Java Beginners
an application that generates a number square like the one below. 1 2 3 4 1 1 2 3 4 2 2 4 6 8 3 3 6 9 12 4 4 8 12 16 Your number square should have the numbers 1...}}; System.out.println("Your Original Matrix: "); for(int i = 0; i < 2; i 

Java Beginners

ARRAYS - Java Beginners
the following link: http://www.roseindia.net/tutorial/java/core/assignSeats.html... Friend, Try the following code: import java.io.*; import java.util.*; import 

Java Tips and Examples

Arrays -- 2-dimensional
Java NotesArrays -- 2-dimensional Multi-dimensional arrays Java..., 2-dim array. Allocation As with all arrays, the new keyword must be used... pointing to the appropriate row array. Processing 2-dimensional arrays Often 

Java Beginners

Java Array Types
Java Array Types  Hi, Can Some one guide me how many types of Java Array uses in developing an application. I need the online tutorial to learn syntax or code of the various types of Java arrays. Thanks 

Java Tips and Examples

Copying Arrays
to learn i.e. copying arrays. It means to copy data from one array to another... length the number of array elements to be copied The following... number 2. Thus the copy begins at the array element 'c'. Now, the arraycopy 

Java Beginners

programme
programme to implement a simple ATM for 15 customers. Initially you have to store... using array(s). Then the program ask user to input account number and password... messages when it is needed. Use at least one array to implement 

Java Beginners

ARRAY SIZE!!! - Java Beginners
). Vector is a growable array. Here no need to define the intial size of ur...ARRAY SIZE!!!  Hi, My Question is to: "Read integers from the keyboard until zero is read, storing them in input order in an array A. Then copy 

Java Beginners

Java Array Values to Global Varibles - Java Beginners
Java Array Values to Global Varibles  I am working on a program... the value of certain mTerm[] and mRate[] arrays, I am unable to get those values... * selection 2 = 15 year loan * selection 3 = 30 year loan 

Java Beginners

Array in Java - Java Beginners
Array in Java  Please help me with the following question. Thank you. Write a program that reads numbers from the keyboard into an array of type... to smallest. For example: For the array -12 3 -12 4 1 1 -12 1 -1 1 2 3 4 2

General

Java Array Length
about array click on: http:/www.roseindia.net/java/language/introduction-to-java... Java Array Length       In this section, you will learn about the java array length. The java array 

General

Basic Java Language Elements
you will be introduced to the concept of Arrays in Java Programming language... Basic Java Language Elements      ... in the program.   Java Comments To comprehend any programming language 

Advertisements Advertisements
 

 

 

DMCA.com