Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java For the next problem, provide function definitions sufficient to solve the

ID: 3585147 • Letter: J

Question

Java

For the next problem, provide function definitions sufficient to solve the problem and tests for those functions, but DO NOT write the code that actually implements the functions. This program should read in a 4x4 matrix from a user in the format of a series of numbers separated by spaces, with the first row comprising the first 4 numbers, the second row the next 4, and so on. The user then has the option to Rotate or Reflect the matrix. If the user chooses to rotate, they should be able to enter ANY integer and the program should print out the result of printing the matrix rotated that many times, where a matrix rotated 1 time is equivalent to a 90 degree rotation, 2 times a 180, 3 times 270, 4 times 360, etc. If the user chooses to Reflect, they should be able to reflect across either the vertical midline or the horizontal midline. The program should print out the result of this reflect. (REMEMBER: you are NOT writing the code to do this. Just defining the functions with empty and the code to test them. For the tests, you don't have to use valid Java to construct the input- as long as it's clear what the input should be from whatever you do write.)

Explanation / Answer

//import util package to use Scanner class

import java.util.Scanner;

public class matrixOperations

{

public static void main(String[]args)

{

//4*4 matrix

int arr[][]={{1,2,3,4}, //1st row

{11,22,33,44}, //2nd row

{5,6,7,8}, //3rd row

{55,66,77,88} //4th row

};

//Scanner object to read input from user

Scanner in=new Scanner(System.in);

//displaying options to choose rotate or reflext

System.out.println("Choose Option");

System.out.println("1.Rotate");

System.out.println("2.Reflex");

int option=in.nextInt();

int rotationNum;

//switch case

switch(option)

{

case 1: System.out.println("Number of times to rotate matrix");

rotationNum=in.nextInt();

rotateMatrix(arr,rotationNum); //calling function to rotate matrix

break;

case 2: System.out.println("1.Vertical Midline");

System.out.println("2.Horizontal Midline");

int reflectOption=in.nextInt();

reflectMatrix(arr,reflectOption); //calling function to reflect matrix

break;

default: System.out.println("wrong option");break;

}

}

//function defintion to rotate array

private static void rotateMatrix(int[][] array, int number)

{

}

//function defintion to reflect array

private static void reflectMatrix(int[][] arr, int reflectOption)

{

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote