008-001-007
Method Definition and Call: Greeting Method
Hard
Problem Description
method Definition and Call: Greeting method
In this problem, you will create a program that defines greet and introduce methods in a Greeter class, calls them from the Main class, and displays greeting messages to standard output.
Learning Objective: Define methods and call them for execution
Create a program that defines and calls greeting methods. Learn basic method definition and invocation.
Input
Line 1: Name (string)
Output
Hello, [name]!
Nice to meet you!
Specifications
- Define greet and introduce methods in Greeter class
- greet(String name): Output "Hello, [name]!"
- introduce(): Output "Nice to meet you!"
- Call both methods in Main class
Examples
Example 1
Input:
Taro
Output:
Hello, Taro!
Nice to meet you!
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