Menu
Question Index
...

Write a program to encrypt the given word using the character map.

Input (Map, String) Output (String)
[P=>M, O=>X, T=>N, A=>Y], TOP NXM
[P=>M, O=>X, T=>N, A=>Y], TATTOO NYNNXX
[P=>M, O=>X, T=>N, A=>Y], POT MXN
[P=>M, O=>X, T=>N, A=>Y], TATA NYNY
[P=>M, O=>X, T=>N, A=>Y], APTO YMNX


import java.util.*;
class EncryptWordUsingMap
{
    public static void main(String s[])
    {
        Map<Character, Character> map = new HashMap<Character, Character>();
        map.put('P', 'M');
        map.put('O', 'X');
        map.put('T', 'N');
        map.put('A', 'Y');
        System.out.println("The code for a 'TOP' : " + encryptWord(map, "TOP"));

    }


    public static String encryptWord(Map<Character, Character> map, String input) {
    }

}

Doubts

Problems

Topic: Java HashMap Implementation

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App