Kotlin Plz!!!
Posted: Mon Jun 06, 2022 4:34 pm
Kotlin Plz!!!
Write a function called centerString with the following signature (parameters) fun centerstring( str: String, columnwidth: Int = 80, padChar : string = "") :string { } This function should take the string and center it inside another string of size "columnWidth" with padChar characters on either side of the string that is passed in. Use some simple calculations to determine where the string is supposed to start in the larger columnWidth string. This function should not print anything but return the string centered and padded appropriately. The columnWidth should have a default parameter of 80 and the padChar should have a default of a single space string. For example this centerstring( "Dave", 20 ) would return a string Dave with 8 spaces before Dave and 8 spaces after for a total of 20 characters which matches the column width.
Write a function called centerString with the following signature (parameters) fun centerstring( str: String, columnwidth: Int = 80, padChar : string = "") :string { } This function should take the string and center it inside another string of size "columnWidth" with padChar characters on either side of the string that is passed in. Use some simple calculations to determine where the string is supposed to start in the larger columnWidth string. This function should not print anything but return the string centered and padded appropriately. The columnWidth should have a default parameter of 80 and the padChar should have a default of a single space string. For example this centerstring( "Dave", 20 ) would return a string Dave with 8 spaces before Dave and 8 spaces after for a total of 20 characters which matches the column width.