008-004-001
Multiple Parameters Method: Greeting Program
Easy
Problem Description
Multiple Parameters method: Greeting Program
In this problem, you will create a program that defines a greet(String name, int age, String hometown) method, reads name, age, and hometown from standard input, passes them as arguments to the method, and displays a greeting message to standard output.
Learning Objective: Define methods with multiple parameters
Create program displaying greeting with three information pieces: name, age, hometown. Pass multiple arguments to greet method.
Input
Line 1: Name (string)
Line 2: Age (integer)
Line 3: Hometown (string)
Output
Hello, [name]!
You are [age] years old from [hometown].
Nice to meet you!
Test Cases
※ Output examples follow programming industry standards
Input:
Taro 20 Tokyo
Expected Output:
Hello, Taro! You are 20 years old from Tokyo. Nice to meet you!
Input:
Hanako 25 Osaka
Expected Output:
Hello, Hanako! You are 25 years old from Osaka. Nice to meet you!
Input:
A 0 B
Expected Output:
Hello, A! You are 0 years old from B. Nice to meet you!
Input:
Ken 99 Kyoto
Expected Output:
Hello, Ken! You are 99 years old from Kyoto. Nice to meet you!
❌ Some tests failed
Your Solution
Current Mode:● My Code
99
1
2
3
4
5
6
7
8
9
10
›
⌄
⌄
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here
sc.close();
}
}
0 B / 5 MB
You have 9 free executions remaining
