008-001-011

Method Definition: Method Collaboration

Hard

Problem Description

method Definition: method Collaboration

In this problem, you will create a StringProcessor class where process() calls both addPrefix() and addSuffix(), then read a string from standard input and print the decorated result.

Learning Objective: Understand how to call one method from another

Overview

Create a class where multiple methods work together.

Specifications

  • Create a StringProcessor class
  • addPrefix(String s) adds '>>' to the beginning of the string and returns it
  • addSuffix(String s) adds '<<' to the end of the string and returns it
  • process(String s) calls both addPrefix and addSuffix and returns the combined result
  • In the Main class, read one line from standard input and print the result of process()

Input

A string (one line)

Output

>>string<<

Input/Output Examples

Input: Hello
Output: >>Hello<<

Input: World
Output: >>World<<

Input: (empty string)
Output: >><<

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up