Function Implementation


Submit solution

Points: 45 (partial)
Time limit: 1.0s
Memory limit: 64M

Authors:
Problem type

題目說明

請實作兩個函式 greetUserfarewellUser,並在 main 函式中呼叫它們,使程式能夠正確執行。

請務必依照下方程式碼模板作答,不得修改主程式的結構,否則不予計分!

程式碼模板 (請務必依照此模板撰寫)

import java.util.Scanner;

public class FunctionImplementation {
    public static void main(String[] args) {
        greetUser();
        farewellUser();
    }

    // 請實作 greetUser 函式,使其輸出 "Hello! Welcome to the program."

    // 請實作 farewellUser 函式,使其詢問使用者的姓名,然後輸出 "Goodbye, [name]!"
}

輸入

farewellUser 函式應該要求使用者輸入自己的名字。

輸出

greetUser 會輸出 "Hello! Welcome to the program."

farewellUser 會先輸出 "Enter your name:",然後讀取使用者輸入的名字,並輸出 "Goodbye, [name]!"

範例輸入 #1

Alice

範例輸出 #1

Hello! Welcome to the program.
Enter your name:
Goodbye, Alice!

Comments

There are no comments at the moment.