Create a class called CIE106Finals. Inside the class, Implement the two methods; equalInHas(String str) and reOrder56(Int[] nums) described below

computer science

Description

Question 1 Create a class called CIE106Finals. Inside the class, Implement the two methods; equalInHas(String str) and reOrder56(Int[] nums) described below. Use the main( ) to test each of the two methods by storing there return values Inside a variable and using println( ) to output the values In those variables. 


• Given a string of characters, write a static method equalInHas(String str) that returns true if the number of occurrences of "in" anywhere in the string is equal to the number of occurrences of "has" anywhere in the string (case sensitive). e.g equalInHas ("inside the vessel it has to be or not in") → false equalInHas ("Thin has ") → true equalInHas("hasviooininhshastyion") → true Note: only a single loop is allowed 


• Write a static method reOrder56(int[] nums) that return an array that contains exactly the same numbers as the given array, but has been reorderd so that every 5 is immediately followed by a 6. You may choose to move every other number with the exception of 5; You are not to move 5. The array contains the same number of 5's and 6's, every 5 has a number after it that is not a 5, and a 6 appears in the array before any 6.

Instruction Files

Related Questions in computer science category