Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

using basic java please Task 4: Pad String Write a method called padString that accepts two parameters: a string and an integer representing a length.

using basic java please

image text in transcribed

Task 4: Pad String Write a method called padString that accepts two parameters: a string and an integer representing a length. The method should pad the parameter string with spaces of the given length. For example padString("hello", 8) should print" hello". Since hello is only 5 characters we need to pad it with 3 spaces to get it to be 8 in length. If the strings length is already as long as the parameter, your method should print he original string. For example, padStrins("congratulations", 15) should print "congratulations"; there is no padding because there are 15 letters in congratulations Complete the program by having the main method that call padString) with the values from the above and prints the results to the console

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

The Temple Of Django Database Performance

Authors: Andrew Brookins

1st Edition

1734303700, 978-1734303704

More Books

Students also viewed these Databases questions