Question: 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

using basic java please Task 4: Pad String Write a method called

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!