Write the following program in two parts use careful design

Write the following program in two parts, use careful design, correct features, and proper style. Write complete pseudo code for each part and include it as comments in the program. Call your class Numbers and put both part 1 and part 2 in a single .java file that you submit in Sakai. Write a function called isNumbersPresent that returns a boolean value and takes two parameters. The first parameter is an array of ints called numbers. Each element can be positive, negative, or zero. The second parameter is an array of ints called guesses. Each clement of the second array is also an int. The function checks to sec if *all* of the ints in guesses (the second parameter) are present in numbers (the first parameter) If so, return true, otherwise false. You must use two arrays of ints as formal parameters. The function must work with parameters of any size. The function docs not prompt the user. REQUIRED: ***Before you write any code for the function, write in English a good pseudo code description of how the program will work. Include your English description at the top of the function code as comments*** Examples of what the function does: If numbers has -3, 10, 999, 74, 0, 34 as its elements, and guesses has 34, 10 as only elements, return true. If numbers has 99, 1000, 45, 6 as its elements, and guesses has 99, 1000, 45, 7, 6, return false. Every number in guess must be in numbers to return true. Make sure your code handles simple eases such as numbers has only one number. Make sure your code handles duplicate numbers in both numbers and guesses. If numbers has 34, 7, 35, 9, 9 and guesses has 9, 7 return true (all of guesses are in numbers)

Solution

public static boolean isNumbersPresent(int numbers[], int guesses[]) {
       for(int i = 0; i < guesses.length; i++){
           boolean found = false;
           for(int j = 0; j < numbers.length; j++){
               if(guesses[i] == numbers[j]){
                   found = true;
                   break;
               }
           }
           if(!found) return false;
       }
       return true;
   }

 Write the following program in two parts, use careful design, correct features, and proper style. Write complete pseudo code for each part and include it as co

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site