Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package softuni;
- import java.util.Scanner;
- public class SoftUni {
- static String encriptionMethod(int amount){
- Scanner sc = new Scanner(System.in);
- String text = "";
- int count = 0;
- while(count < amount){
- char letter = sc.next().charAt(0);
- int ascii = (int)letter;
- String asciiStr = Integer.toString(ascii);
- char first = asciiStr.charAt(0);
- int firstInt = Integer.parseInt(String.valueOf(first));
- int lastInt = ascii%10;
- char comb1 = (char) (ascii+lastInt);
- char comb2 = (char) (ascii-firstInt);
- String text1 = comb1 + (Integer.toString(firstInt)+ "" + Integer.toString(lastInt)) + comb2;
- text += text1;
- count++;
- }
- return text;
- }
- public static void main(String[] args){
- Scanner sc = new Scanner(System.in);
- System.out.print("Enter the amount of numbers here: ");
- int amount = Integer.parseInt(sc.nextLine());
- System.out.println(encriptionMethod(amount));
- }
- }
Add Comment
Please, Sign In to add comment