Get the game mode

Report a typo

Imagine your program is a game and it can accept command line arguments to set game parameters such as game mode, game level, etc. These arguments are provided in pairs: the parameter name and its value. If any parameter name is not passed as a command line argument, its value is set to default.

Write a program that accepts an array of command line arguments, searches for the parameter named mode and displays its value. The Input is a sequence of pairs: the parameter name is followed by the parameter's value. Please note that the word mode can occur only once as a parameter name but can occur multiple times as a parameter value.

If no parameter with the name mode is provided, the program must print its default value: default.

Sample Input 1:

level beginner mode battle

Sample Output 1:

battle

Sample Input 2:

parameter1 mode parameter2 value2

Sample Output 2:

default
Write a program in Java 17
class Problem {
public static void main(String[] args) {

}
}
___

Create a free account to access the full topic