Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a method called roundAllUp(), which takes in an array of doubles and returns a new array of integers. This returned array contains all the

Create a method called roundAllUp(), which takes in an array of doubles and returns a new array of integers. This returned array contains all the numbers from the array of doubles, but rounded up. Below are some example input-output pairs:

[1.0, 3.5, 3.2, 4.1] -> [1, 4, 4, 5] [1.1, 3.0, 0.5] -> [2, 3, 1]

Write a method isPalindrome() that takes in a String and returns true if it is a palindrome, meaning it is the same string if it is reversed.

Write a method named minGap that takes in an array of integers and returns the minimum gap between values in the array. The gap between two adjacent values in an array is defined as the second value minus the first value. For example, suppose we have the following array:

[1, 3, 6, 7, 12]
The first gap is between indices 0 and 1 and its value is 3  1 = 2. The second gap is 6  3 = 3. The smallest gap is 1, which is between indices 2 and 3. 

And finally, you need to call these methods from your main method. The sequence of the method calls are something like below:

double [] doubleArray = {1.8, 2.3, 3.9, 5.0, 6.01}; int [] intArray = {1, 23, 53, 58, 85, 100, 122}; String str = "Madam"; int [] roundUpArray = roundAllUp(doubleArray) ; System.out.println("After rounding up: "); //print every element of the roundUpArray System.out.println(str + " is Palindrome: "+ isPalindrome(str) ); System.out.println("Min gap array : "); //print every element of the intArray System.out.println("Min gap is: " + minGap(intArray) );

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Nested Relations And Complex Objects In Databases Lncs 361

Authors: Serge Abiteboul ,Patrick C. Fischer ,Hans-Jorg Schek

1st Edition

3540511717, 978-3540511717

More Books

Students also viewed these Databases questions