PLEASE Help With Ceasar Cipher Program!!
This is what I have so far below. The //comments are what I am supposed to do but do not know how. I think I need a driver.java too. PLEASE help. I can attach the .java files if need be.
Code :
import java.io.*;
import java.util.Scanner;
import java.io.*;
public class assign3{
public static void main(String[] args) throws IOException{
Scanner key = new Scanner(System.in);
String choice = key.nextLine(); //Create string variables, choice, input, and output
System.out.println("Do you want to encrypt or decrypt?"); //get the encrypt/decrypt choice
System.out.println("Enter input file");
Scanner keyb = new Scanner(System.in);
String path = keyb.nextLine(); //get the input file path
//get the ouput file path
//create an int variable
//get the key value
//make a new scanner to read from a file
//make a new printwriter to write to the output file
//create cipher object c with int variable as argument
if(choice.equals("encrypt")){
while(/*scanner associated with file has next line*/){
//read a line from the file store it in a string called, say, indata
//create a string variable called, say, outdata
outdata = c.encryptLine(indata);
//write outdata to file
}
}
else{
//do the same for decrypting
}
//close PrintWriter
}
}
Re: PLEASE Help With Ceasar Cipher Program!!
You will increase the probability of receiving a meaningful answer if you ask one question at a time (posting the question outside the code you posted). I say this because I honestly don't know at what step you are stuck, and thus what advice to give.
Break the problem down to the requirements - then ask one question in turn. The following is a good article on how to accomplish this: How to program - stuck on homework?
Re: PLEASE Help With Ceasar Cipher Program!!
It looks like as you copied the whole code from somewhere, coz if you really don't know, what to do with comments, it clearly seems that you copied this and want us to code it for you.
You can't even make a simple initialization? Or you didn't even bother to read that comments?
Remember, we don't do homework for you.