![2 3 4- import java.io.*; import java.util.Scanner: class Main { void exchange(int arr[], int x, int y) // swapping using temp](http://img.homeworklib.com/questions/12008a90-59ff-11eb-be8b-739ad9ec9617.png?x-oss-process=image/resize,w_560)

import java.io.*; import java.util.Scanner; class Main { void exchange(int arr[], int x, int y) { int temp=arr[x]; // swapping using temp variable arr[x]=arr[y]; arr[y]=temp; } public static void main (String[] args) { int list[]={7,9,2,5,10}; //list containing mentioned elements int n,m; Main s1= new Main(); // object of Student class Scanner myObj = new Scanner(System.in); do { System.out.println("Enter value of n and m : "); n=myObj.nextInt(); // take user input m=myObj.nextInt(); // take user input }while(n<0 && m<0 && n>5 && m>5); // to check range of n and m s1.exchange(list,n,m); // clling function for(int i=0;i<5;i++) //print System.out.print(list[i]+" "); } }by netBeans C++ java by netBeans C++ java by netBeans C++ java 1. Answer the following...
*Java* Hi. I need some help with creating generic methods in Java. Write a program GenMethods that has the following generic methods: (1) Write the following method that returns a new ArrayList. The new list contains the nonduplicate (i.e., distinct) elements from the original list. public static ArrayList removeDuplicates(ArrayList list) (2) Write the following method that shuffles an ArrayList. It should do this specifically by swapping two indexes determined by the use of the random class (use Random rand =...
note: the language should be java on netbeans. please solve the question complete. Objective: The students will learn how to work with recursion and improve their problem solving skills. Problem 1: Create an interactive Java Application that has a method to calculate the value of e x = 1 + (x / 1!) + (x2 / 2!) + (x3 / 3!) + … + (xn / n!) Where n and x are supplied by the user. Your must call 2...
Write a java program that has a method called sameArrayBackwards. The method takes an array of integers, and checks if the numbers in the array are the same going forward as going backwards and will return a boolean (true or false) depending on the result. You can assume that there is at least one element in the array. Method Header: public static boolean sameArrayBackwards (int [] arr) You will test your method in the main method of your program by...
java
estion7 For this question, assume all input comes from the keyboard, and al output goes to the screen. Include method prototypes and comments. The array should have room for 100 integers Write a complete Java program, including at least one comment in the main propram and one in e to do the following: Write a main program which will call the methods described below (a) First the main program will read an integer (this integer is a parameter or...
4. [Tests basic knowledge of recursion] Write a recursive static Java method that accepts an array arr of integers argument returns a list of all permutations of these integers. (A permutation of a sequence of integers is a re-arrangement of the integers. For example, one permutation of 1, 3, 4, 8, 2 is 3, 1, 2, 8, 4.) For this problem, you may assume that the input array contains no duplicate entries. Your method should return an ArrayList of int...
Write a java Program Initialize Array. Write a Java method initArray() with the following header to initialize a one-dimensional array a such that the element values (integers) are twice the index value. For example, if i = 23, then a23 = 46. The function is void with one parameter -- the integer array of a[]. Then write a main() with an int[] array2i size 100 to call
First, launch NetBeans and close any previous projects that may be open (at the top menu go to File ==> Close All Projects). Then create a new Java application called "MinMax" (without the quotation marks) that declares an array of doubles of length 5, and uses methods to populate the array with user input from the command line and to print out the max (highest) and min (lowest) values in the array. The methods that determine the max and min...
Valentine’s Day Question(JAVA) Suppose you had a list with 30 valentines and you stored their names in an array (you hopeless romantic). Then if you had 5 people ask to be your valentine, you would need to make a new array of size 35 (30 + 5) and copy over the original valentines before being able to add the new valentines to the array. This question uses the same logic. Write a program that has a method called doubleSize. The...
C++ program by netBeans
java language
Exercise #2: Write a java program that prompts the user to enter a sentence. The program has to find the print: a. the position of vowels in the sentence. b. the number of vowels in the sentence (A, a, U, u, E, e, 0, o, I, i) c. the number of characters as numbers or special characters (other than English letters a..z, A..Z). Hint: remember to ignore the spaces. Sample input-output: Enter the sentnse:...
create a new Java application called "WeightedAvgWithExceptions" (without the quotation marks), according to the following guidelines and using try-catch-finally blocks in your methods that read from a file and write to a file, as in the examples in the lesson notes for reading and writing text files. Input File The input file - which you need to create and prompt the user for the name of - should be called 'data.txt', and it should be created according to the instructions...