Answered step by step
Verified Expert Solution
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
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 consoleStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started