Mathematical Operations: 1) Given the coefficients of a Quadratic Equation, find the array of roots of the
Question:
Mathematical Operations:
1) Given the coefficients of a Quadratic Equation, find the array of roots of the equation. You
may assume that the equation will always have real roots. Round the roots to three Decimal
places. Return the roots in an array of size 2. a method public static double[]
quadraticEquation(double a, double b, double c) to implement this. You may use Math
library only for this question. (5 Points)
2) Given points x1, y1, x2, y2, find the Euclidian distance between the points (x1, y1) and (x2,
y2). You may use Math library only for this question. Round the answer to three Decimal
places. a method public static double euclidianDistance(double x1, double y1, double
x2, double y2) to implement this. (5 Points)
3) Given an array, find the maximum, the minimum, average and total sum of all the elements.
Return the answer in an array of size 4 with each slot corresponding to each answer. a
method public static double[] arrayOperations(double[] a) to implement this. (10 Points)
Methods:
1) a method to reverse a given string. You are required to return the reversed string.
a method public static String strReverse(String a) to implement this. You are not
allowed to use any inbuilt functions for string reversal. (10 Points)
2) Using strReverse(string a) another method to check if a given string is a palindrome. A
palindrome is a word, phrase, or sequence that reads the same backward as forward, e.g.,
madam or nurses run. You are required to return a Boolean value. Write a method public
static boolean checkPalindrome(String a) to implement this. (5 Points)
1D Array:
1) Given a string, calculate the occurrence of each character and store the count in an array.
The length of the output array must be 26 with each slot corresponding to each alphabet.
For example 'a' will correspond to array[0], 'b' will correspond to array[1] and so on. You
may assume that the string consists of only lowercase characters and no spaces. Write a
method called public static int[] strCounter(String a) to implement this. (20 Points)
MD Array:
1) Given a matrix, find the transpose of a matrix. You are required to return a 2-D array. Write
a method called public static int[][] transpose(int[][] a) to implement this. Hint: If the input
matrix are of dimensions M x N, then the output matrix dimensions will be N x M. (20 Points)
2) Given two matrices of dimensions M x N and N x K find the product of the two matrices. You
are required to return a 2-D array. Write a method called public static int[][] matMul(int[][]
a, int[][] b) to implement this. Hint: If the input matrices have the dimensions M x N and N x
K, then the output array dimension will be M x K. (25 Points)
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang