Hey guys! good evening!
hope you can help me with this one.
this is the thing that i want to do!:-Input 2 values : 1 string, and 1 int
-the string should have only letters (cant contain numbers!)
-encrypt the string using the following conditions:
-use the int as encryption
key.
-the key tells how far in the alphabet the String will adjust.so for example,
enter number : 2
enter name: aAaoutput: cCc
this is my code:
int encryptor = 0;
String input = " ";
JOptionPane.showMessageDialog(null,"Welcome");
encryptor = Integer.parseInt(JOptionPane.showInputdialog(null,"Please enter number: ");
input = JOptionPane.showInputDialog(null,"Enter Name: ");
Hey guys! good evening!
hope you can help me with this one.
this is the thing that i want to do!:
-Input 2 values : 1 string, and 1 int
-the string should have only letters (cant contain numbers!)
-encrypt the string using the following conditions:
-use the int as encryption
key.
-the key tells how far in the alphabet the String will adjust.
so for example,
enter number : 2
enter name: aAa
output: cCc
this is my code:
int encryptor = 0;
String input = " ";
JOptionPane.showMessageDialog(null,"Welcome");
encryptor = Integer.parseInt(JOptionPane.showInputdialog(null,"Please enter number: ");
String name= "";
for(int i=0;i<input.length();i++){
input.charAt(i);
int x = (int) input.charAt(i);
x=x+encryptor;
char y = (char) x;
name = name +y;
}
JOptionPane.showMessageDialog(null,name);
and aside from that, i still have a problem for example
the user will input 1 as an encryptor
and inputted 'z'
it should print 'a'
meaning it would go back to the beginning and i dont know how to do that
im using ASCII
thanks guys