Kotlin Plz!!!

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Kotlin Plz!!!

Post by answerhappygod »

Kotlin Plz!!!
Kotlin Plz 1
Kotlin Plz 1 (40.43 KiB) Viewed 28 times
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.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply