Write a static method that takes multiple formal parameters


Assignment

The lab this lesson introduces students to static methods. By the end of this lab, students should be able to

Write a static method that takes multiple formal parameters

Invoke a static method that takes multiple actual parameters

Use the returned value of a method

Write and call overloaded methods

Implement the following methods:

// Write a method that returns true if s has leading or trailing whitespace, false otherwise public static boolean needsTrim(String s)

// Write a method that swaps the first three and last four characters of s public static String swap3For4(String s)

// Write a method that has one String parameter, and returns true if the first half and last half of the parameter are the same ignoring case, and false otherwise. (The name of the method is up to you.)

Use these methods to rewrite the corresponding parts of the String Play program of Unit Strings.

String Play program-

Question-

Write a program using Scanner and its nextLine method. The following is an example of how to use nextLine Scanner kybd = new Scanner(System.in);

System.out.println("Enter a line of text");

String aLine = kybd.nextLine();

You may assume that the user input has at least 7 characters.

Print either "the original String has no leading or trailing whitespace" or "the original String has leading or trailing whitespace." (Hint: the trim method will be a good start, but you'll need more.)

Swap the first three and last four characters of aLine and print the result.

Print aLine in all upper case.

Print the compareTo results of comparing aLine in all lower case with the original aLine. (This will be a number.)

Print whether the first half of aLine is the same as the last half of aLine except for case.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Write a static method that takes multiple formal parameters
Reference No:- TGS02779218

Expected delivery within 24 Hours