Question: in java Objective and Overview: This lab exercise is a revision on Methods, Arrays and Files. Directions: 1. Open your Netbeans, create a new Java


Objective and Overview: This lab exercise is a revision on Methods, Arrays and Files. Directions: 1. Open your Netbeans, create a new Java Application project. Call your project: Lab_1_Hoda_Mona, where Hoda and Mona are the names of the team members of your group. Please refer to the video on how to create your Java Application Project posted with this lab. Problem 1 (methods): Create a class and call it Problem 1. In that class, write the following methods and test them in the main method: 1. A Java method to determine and return an appropriate value indicating if a number K is odd or not, where K is received as a parameter. The header of the method is as follows: public static boolean isOdd(int x) 2. A Java method to determine and return the product of multiplying three integer numbers, where the three numbers are received as parameters. The header of the method is as follows: public static int product (int x, int y, int z) 3. A Java method to determine return the largest among three numbers. public static int largestNum (int x, int y, int z) 4. A java method to take a character and a number N, then it repeats printing this character CN number of times. public static void printCharacter (char C, int N) Example: if Cis. Nis 5 Output should be ***** 5. A java method to take a character and two numbers N, M, then it repeats printing this character CN number of rows and M number of columns. public static void printCharacter2(char C, int n, int M) Example: if C is '*, Nis 5, M is 3 Output should be ***** ***** 6. A Java method to determine and return the maximum of Nintegers. The number of integers N is received as a parameter. The method should prompt the user to enter the N numbers, then it return the highest. The header of the method is as follows: public static int max(int n) Problem 2 (Arrays): In the same package, create another Java class and call it Problem_2. Solve the following problems: 1. Write a method to print an array of double values 10 elements in each row. public void printArray (double[] arr) In the main method, create an array of double of size=30 and print it. 2. Write a method that takes an array of double and initializes it to random numbers between a minimum value and a maximum value public void fillArray (double[] arr, double min, double max) In the main method, fill this array with random numbers between 20 and 200, then print it. 3. Write a method that returns the average of an array of double numbers with the following headers: public static double average double[] array) In the main method display the average of the numbers in your array. 4. Write a method that finds the largest element in an array of double values public static double largest double[] array) In the main method, find and print the largest value in the array 5. Write a method that finds the smallest element in an array of double values public static double smallest(double[] array) In the main method, find and print the smallest value in the array 6. Write a method that returns true if list is sorted, using the following header: public static boolean is Sorted int[] list) In the main method, create two arrays of 5 elements, and fill them one with sorted elements and another with unsorted elements. Test both arrays to see if they are sorted or not and print the result. Problem 3 (Files): in the same package, create another Java class and call it Problem_3. Solve the following problems: 1. A Java method to determine and return the number of times a word is present in a file, where the filename and word is received as parameters. The header of the method is as follows: public static int countWordsInFile(String filename, String word) 2. Create an input file and add some words in it. Then test your method by searching for any word in that file. Test twice, once with a word that is found, and another time with a word that is not found. 3. A Java method to count and return the number of lines, words, and characters in an input file (Do not count spaces as characters). It returns the required information in an array of integers. public int[] filelnfo (String filename) 2 4. Use the same input file you created in the previous question and output the number of lines, words, and characters in that file. When 5. A Java method to convert words in a file into all capital letters and writes the output to an output file. The header of the method takes the input file name and the output file name: public void convert (String inputFileName, String outputFileName) 6. Test your method in the main method using the same input file you created. Use a different file name as your output file
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
