008-001-004
Method Definition and Call: Greeting Message
Medium
Problem Description
method Definition and Call: Greeting Message
Learning Objective: Understand how to define and call methods
In this problem, you will create a program that defines a method (e.g., greet(String name)) which takes a name as an argument and prints a two-line greeting message, then calls it from the main method and displays the result to standard output.
Create a program that defines and calls a method to display a greeting message with a given name.
Input
Line 1: Name (string)
Output
Hello, [name]!
Nice to meet you.
Example
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