Code Below:


import java.util.*;
class encode
{
    String s;
    String str;
    
    void input(String st)
    {
        s=st;
        str="";
    }
    
    void perform(int move)
    {
        int l=s.length();
        for (int i=0;i< l;i++)
        {
            char ch=s.charAt(i);
            int asc=ch+move;
            if(asc>90)
            asc=64+(asc- 90);
            if (asc< 65)
            asc=asc+26;             //adding the inputted value to the ASCII of the string's character
            str=str+(char)asc;
        }
    }
    
    void display()
    {
        System.out.println(s);
        System.out.println(str);
    }
    
    public static void main()
    {
        encode obj=new encode();
        Scanner in= new Scanner(System.in);
        System.out.println("enter a string");
        String st=in.nextLine();
        obj.input(st);
        System.out.println("enter the value");
        int move=in.nextInt();
        obj.perform(move);
        obj.display();
    }
}