• 0

[JAVA] Errors in the Code!


Question

Hey guys,

I was just making a small file to encrypt data entered by user by using the Key:

Here's the code:

import java.io.*;
public class Encryption{
	public static void main(String[]args)throws IOException{
		InputStreamReader instream=new InputStreamReader(System.in);
		BufferedReader hash=new BufferedReader (instream);
		System.out.println ("Plz enter string");
		String s=hash.readLine();
		System.out.println("Plz enter the Key");
		int key=hash.readInt();
		int x;
		for (int i=0; i<s.length(); i++){
		int x= (char)s.char At(i) + key;
		System.out.println(x);
		}

	}
}
}

I don't know there are alotta errors (4)

Identifier in line (12) and <expression> in line 12

the main problem is mainly in line (12) but I can't figure it out, I've tried alotta things but it ain't working ://

Edited by MostafaKamel
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

import java.io.*;
import java.util.Scanner;

public class Encryption {
	public static Scanner instream = new Scanner(System.in);
	public static Scanner hash = new Scanner(System.in);

	public static void main(String[]args)throws IOException {
		System.out.println ("Plz enter string");
		String s = instream.nextLine();
		System.out.println("Plz enter the Key");
		int key = hash.nextInt();
		for (int i = 0; i &lt; s.length(); i++){
			System.out.println(s.charAt(i) + key);
		}
	}
}

That should take care of it...

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.