002-002-004

String Input: Message Card Creation

Easy

Problem Description

String Input: Message Card Creation

Learning Objective: Input multiple strings using nextLine() method

In a message card creation program, input sender and recipient names to display the card.
Practice inputting multiple strings in sequence.

Input

Line 1: Sender name (string)
Line 2: Recipient name (string)

Output

================================
     Message Card
================================
From: [sender]
To: [recipient]
Thank you!
================================

Test Cases

※ Output examples follow programming industry standards

Input:
Taro Tanaka
Hanako Sato
Expected Output:
================================
  Message Card
================================
From: Taro Tanaka
To: Hanako Sato
Thank you!
================================
Input:
Alice
Bob
Expected Output:
================================
  Message Card
================================
From: Alice
To: Bob
Thank you!
================================
Input:
A
B
Expected Output:
================================
  Message Card
================================
From: A
To: B
Thank you!
================================
❌ Some tests failed
❌ エラー発生

Your Solution

Current Mode: My Code
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
// キーボード入力を読むためのScannerオブジェクトを作成
Scanner sc = new Scanner(System.in);
// 送信者名を入力
String from = sc.nextLine();
// 受信者名を入力
String to = sc.nextLine();
// メッセージカードを表示
System.out.println("================================");
System.out.println(" Message Card");
System.out.println("================================");
System.out.println("From: " + from);
System.out.println("To: " + to);
System.out.println("Thank you!");
System.out.println("================================");
}
}

0 B / 5 MB

You have 10 free executions remaining