Reputation: 115
//8.
//----------------------------------------------------------------
//-------- Display orignal and encrypted message information
//----------------------------------------------------------------
private void displayEncryptedMessage(String originalMessage, String encryptedMessage) {
System.out.println("");
System.out.println("");
System.out.println("");
System.out.println("Enter Message to be encrypted: ");
System.out.println("");
System.out.println("");
System.out.println("");
System.out.println(" Plain Text : " + originalMessage);
}
// 9
//----------------------------------------------------------------
// Encrypted it by substituting the character with the corresponding character in the cipher.
//
//----------------------------------------------------------------
private void encrypt(String cipher){
int letterPosition;
String encryptedMessage = "";
String originalMessage = Keyboard.readInput();
displayEncryptedMessage(String originalMessage, String encryptedMessage);
for (letterPosition=0; letterPosition<originalMessage.length(); letterPosition++){
char replaceCipherLetter = cipher.charAt(letterPosition);
encryptedMessage += replaceCipherLetter;}
System.out.println(" Cipher Text: " + encryptedMessage);
}
Im really new to Java so all your comments will be GREATLY appreciated... SInce method 8. is void, it doesnt return any values right? If I wanted to put 8 into 9, displayEncryptedMessage(String originalMessage, String encryptedMessage);
, is that what Id put as the parameters ? and why do I get these errors?
Error: ')' expected
Error: illegal start of expression
Upvotes: 0
Views: 304
Reputation: 4701
While calling the method, you need to pass the values like:
displayEncryptedMessage(originalMessage, encryptedMessage);
Declaring the type of parameter that method will accept, is part of method definition.
Note: Method can also accept the Type or Subtype of the type.
Upvotes: 0
Reputation: 3462
When you are calling the method , you have to only pass the values , type declaration is not allowed while method calling.
displayEncryptedMessage(String originalMessage, String encryptedMessage);
should be
displayEncryptedMessage(originalMessage, encryptedMessage);
Upvotes: 11