Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1) Code a method named eye that takes as input a positive integer d and prints out an identity matrix of size (dxd). An identity
1) Code a method named eye that takes as input a positive integer d and prints out an identity matrix of size (dxd). An identity matrix is defined as a matrix with 1s on the diagonal and 0s everywhere else. For example, if the user enters 3 , your program should print out the matrix: 100010001 The method does not return anything. Hint: Use nested loops. 2) Code a method named findMyString that takes two input variables, arr and key. Assume that the key is only a single String and that arr is an array of Strings of any length. Your method should search for key in arr and returns the first position (index) of its appearance in the array. In the case the key is not found, your output should be 1. 3) Code a method called reverseArrayToArrayList that turns any array into an ArrayList and returns it in the reverse order (without using any built-in Java support for this). Provide an example that proves your code works. Test all your methods in your main appropriately
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started