1. String manipulation is NOT allowed for this project. 2. You may not import any extra functionality besides the default. For example, System and Math are imported by default and thus may be used,...

1 answer below »
Hello I attached the document which has the description of my java assignment. I need to implement a couple of methods using simple arithmetic operations and basic array methods. I need help implementing them. If someone can please help me with them it's highly appreciated.


1. String manipulation is NOT allowed for this project. 2. You may not import any extra functionality besides the default. For example, System and Math are imported by default and thus may be used, whereas something like ArrayList must be explicitly imported so it is disallowed. 3. The main method will not be tested; you may use it any way you want. 4. Comment your code, especially the parts that is not obvious what you're doing. Number Methods: You can accomplish this section using simple arithmetic operations (integer division, multiplication, and modulus). REMEMBER: String manipulation is not allowed for this project. · (10 pts) A mirror number has its digits on the reverse order of a given number. For instance, 1 is mirror of 10, 100, and so on. Likewise, 34 is a mirror of 43. Implement a method mirrorNumber() that takes in an integer, and returns mirror integer. You can assume the input integer is positive, and ignore zeros left of the mirror number. Use the method signature: public static int mirrorNumber(int input) inputs return 7 7 10 1 1450 541 34 43 11711 11711 · An odd stripped number is one whose odd digits have been removed. For instance, 77 results in 0, 47 results in 4, or 10007 results in 0. Write a method that takes in an integer, and returns an odd stripped integer. You can assume the input integer is positive, and ignore zeros left of the odd stripped number. Use the method signature: public static int stripOdds(int input) input return 1 0 2 2 34 4 556550 60 77 0 · A hidden prime is an integer that is not a prime number, yet at least a prime number within its digits can be exposed. For instance, 24 has a prime one (2) hidden, 890 has one (89), or 77 has 2 (7 twice). However, nor 2 nor 23 are considered to have hidden prime numbers, since they are prime numbers themselves. Write a method that takes a long number, and checks that it has hidden prime numbers, and returns true if so, otherwise, returns false. You can assume the input number to be positive and finding the first hidden prime will suffice. Use the method signature: public static boolean hasHiddenPrime(long input) input return 2 false, 2 is prime 32 true, 32 is not prime, 3 and 2 are hidden primes 0 false 77 true, 77 is not prime, 7 is a hidden prime 890 true, 890 is not prime, 89 is a hidden prime 9669 false, 9669 is not prime, there are no hidden primes · A cozy number is a number that can be found within another number. For instance, given 24 and 2, 2 can be found in 24. Similarly, given 507789 and 77, 77 is a cozy number within 507789. Write a method that takes two(2) integers, and checks that the first input allows the second input to be a cozy number, and returns true if so, otherwise, returns false. You can assume the input numbers to be positive and finding the first occurrence will suffice. Use the method signature: public static boolean isCozyNumber(int input1, int input2) input return (9,9) true, 9 is cozy within itself (9,7) false, 7 is not found in 9 (270, 70) true, 70 is cozy within 270 (107744, 74) true, 74 iz cozy within 107744 (7, 17) false, 17 is not cozy within 7 Array Methods: · ( Let us play Number Jack, a simple and number based version of blackjack, a player has 3 cards drawn, if the cards add up from 17 to 21, the player wins, otherwise the player loses. Each card may hold a value between 1 and 10. This lends itself to a simple implementation in code. Write a method named isNumberJackWinner() that takes an array of integer values, and determines if the card amount (3) and values (between 1 and 10) are valid and the sum of the 3 cards are below or equal to 21, and returns true if so, otherwise returns false. Use the following signature for your method. public static boolean isNumberJackWinner(int[] array) input array return [9, 9, 1] true, the player wins: card count is 3, the three cards are between 1 and 10, and the total is 20 [9, 8] false, the player loses: card count is 2, it must be 3 [1, 70, 10] false, the player loses: the second card (70) is invalid [1,1,1] false, the player loses [7,7,10] false, the player loses: the sum of the cards (24) is greater than 21 · Write a method array2matrix that takes an array that holds data for L numbers, and returns a reconstruction of the original array as a matrix of MxN assuming that: · The first element of the input array holds M, the amount of rows the returned matrix will have · The second element of the input array holds N, the amount of columns the returned matrix will have · The rest of the elements of the input array will fill up the returned MxN matrix row by row · The remaining elements of returned matrix should have a value of 0 if the input array does not have enough elements Assume the values L, M, N are positive. The minimum size of the input array is 2, and its max size may exceed the available space in the returned matrix. Use the following signature for your method. public static int[][] array2matrix(int[] array) input array returned matrix [2,1,3] [[3],[0]] [5,4,-8,4,3,7,64] [[-8,4,3,7],[64,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]] [2,2,1,2,3,4] [[1,2],[3,4]] · Let us play battlecraft, an interstelar and simple version of battleship. Given a map with the coordinates of enemy battlecrafts, in the form of a MxN matrix holding the combat identification of the enemy targets. You have 3 shots to hit a target, represented with 3x2 matrix, where each row are the coordinates in the map matrix to hit. Write a method shootBattleCraft that takes as inputs the map (MxN) matrix and the shot coordinates (3x2) matrix, and if a shot hits a battlecraft, replace its combat id number with -1. Assume both matrixes' sizes and values are valid. Use the following signature for your method. public static void shootBattleCraft(int[][] battleMap, int[][] shotCoordinates) input map matrix input shot coordinates map matrix after shots [[0,0,0],[0,707,0],[0,0,0]] [[0,0],[2,2],[1,1]] [[0,0,0],[0,-1,0],[0,0,0]] [[0,0,0],[0,707,0],[0,0,0]] [[0,0],[2,2],[1,0]] [[0,0,0],[0,707,0],[0,0,0]] [[0,0,0,0,101],[0,707,0,0,0],[64,0,0,0,0]] [[0,4],[2,2],[2,0]] [[0,0,0,0,-1],[0,707,0,0,0],[-1,0,0,0,0]]
Answered 28 days AfterSep 01, 2022

Answer To: 1. String manipulation is NOT allowed for this project. 2. You may not import any extra...

Uhanya answered on Sep 07 2022
70 Votes
1. String manipulation is NOT allowed for this project.
2. You may not import any extra functionality besides the default. For example, System and Math are imported by default and thus may
be used, whereas something like ArrayList must be explicitly imported so it is disallowed.
3. The main method will not be tested; you may use it any way you want.
4. Comment your code, especially the parts that is not obvious what you're doing.
Number Methods:
You can accomplish this section using simple arithmetic operations (integer division, multiplication, and modulus).
REMEMBER: String manipulation is not allowed for this project.
· (10 pts) A mirror number has its digits on the reverse order of a given number. For instance, 1 is mirror of 10, 100, and so on. Likewise, 34 is a mirror of 43. Implement a method mirrorNumber() that takes in an integer, and returns mirror integer. You can assume the input integer is positive, and ignore zeros left of the mirror number.
Use the method signature:
public static int mirrorNumber(int input)
    inputs
    return
    7
    7
    10
    1
    1450
    541
    34
    43
    11711
    11711
· An odd stripped number is one whose odd digits have been removed. For instance, 77 results in 0, 47 results in 4, or 10007 results in 0. Write a method that takes in an integer, and returns an odd stripped integer. You can assume the input integer is positive, and ignore zeros left of the odd stripped number.
Use the method signature:
public static int stripOdds(int input)
    input
    return
    1
    0
    2
    2
    34
    4
    556550
    60
    77
    0
· A hidden prime is an integer that is not a prime number, yet at least a prime number within its digits can be exposed. For instance, 24 has a prime one (2) hidden, 890 has one (89), or 77 has 2 (7 twice). However, nor 2 nor 23 are considered to have hidden prime numbers, since they are prime numbers themselves. Write a method...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here