Java 我如何让这个程序打印编码信息?

Java 我如何让这个程序打印编码信息?,java,Java,如何使用下面的代码仅使用用户输入的编码字和模式打印出解码字。到目前为止,我能够让程序设置所有变量,我只是不知道如何在每个字母后减去模式量,然后将其放入一个编码字中 这是我到目前为止所拥有的 import java.util.*; public class happy{ public static void main (String [] args){ Scanner inputScanner = new Scanner(System.in); //imports scanne

如何使用下面的代码仅使用用户输入的编码字和模式打印出解码字。到目前为止,我能够让程序设置所有变量,我只是不知道如何在每个字母后减去模式量,然后将其放入一个编码字中

这是我到目前为止所拥有的

import java.util.*;

public class happy{

public static void main (String [] args){ 

      Scanner inputScanner = new Scanner(System.in); //imports scanner reader

System.out.println("\nplease enter a code to decrypt");
    String userinput0 = inputScanner.next(); //assigns the word entered by user to varible userinput
    System.out.println("please enter the pattern for the decryption");
    String userinput1 = inputScanner.next(); //assigns the word entered by user to varible userinput
    int inputting2 = Integer.parseInt(userinput1); //changes the string value to integer value

   // for(int yt = 0; yt < yu; yt++){

     // System.out.print(charArray[yt]);

      for(int hh = 0; hh < inputting2; hh--){
System.out.println();

      } //end of for loop
   // } //end of for loop

}
}
import java.util.*;
公众阶级快乐{
公共静态void main(字符串[]args){
Scanner inputScanner=新扫描仪(System.in);//导入扫描仪读取器
System.out.println(“\n请输入要解密的代码”);
String userinput0=inputScanner.next();//将用户输入的单词分配给可变的userinput
System.out.println(“请输入解密模式”);
String userinput1=inputScanner.next();//将用户输入的单词分配给可变的userinput
int inputing2=Integer.parseInt(userinput1);//将字符串值更改为整数值
//for(int-yt=0;yt
你可以试试这个……这是用来解密的

encryptedText
是要解密的加密文本,模式为
int

Scanner scn = new Scanner(System.in); //imports scanner reader

System.out.println("\nplease enter a code to decrypt");
String encryptedText = scn.nextLine(); //assigns the word entered by user to varible userinput
System.out.println("please enter the pattern for the decryption");
int pattern = scn.nextInt(); //changes the string value to integer value
scn.nextLine();

for (int x=0; x<encryptedText.length(); x+=(pattern+1))
    System.out.print(encryptedText.charAt(x));

你想做一个Vigenère密码吗?嗯,我不确定那是什么,但我会给你一个它应该如何运行的例子:-假设用户输入的代码是:Haedlsos-模式是1-程序应该打印HELLO作为解码消息,所以程序必须能够根据模式找到随机字母并删除它们然后把这个字打印出来你是说在1,3,5,7…等位置去掉一个字符?如果模式是3怎么办?如果模式是3,那么每个字母之间会有mroe随机字母示例单词是HELLO编码单词会是HedfEsdfLetrLdwrOersok但当我粘贴它时,我应该将str和模式设置为什么?它们不能被重新使用。我的代码可以工作,但您的原始代码需要一些编辑。。我会在回复中告诉你要编辑什么。我需要切换什么?再次复制并粘贴所有内容,我已经编辑了。str不应该在那里。非常感谢!!我已经在这上面呆了一段时间了,再次谢谢你
please enter a code to decrypt
a..p..p..l..e..i..s..g..o..o..d..
please enter the pattern for the decryption
2
appleisgood