Question: You are to change the following in the Decode.java class. Add the code that will decode the encodedMsg instance variable. You should use the while

You are to change the following in the Decode.java class.

Add the code that will decode the encodedMsg instance variable. You should use the while loop so that your code will decode any encoded string. Store the decoded string result in the decodedMsg instance variable.

Messages are decoded by subtracting 5 from the ASCII integer representation of the character in a string.

Note: The method encodedMsg does not return a value.

You should make the necessary changes to Decode.java and then compile and correct any errors. Once there are no errors, you should then run the TestDecode.java to test the Decode.java class. You are free to change the string that will be encoded. Do not alter any other code in the TestDecode.java program

//******************************************************************** // TestDecode.java // // This program will test the Decode class. // //********************************************************************

public class TestDecode { public static void main(String[] args) {

// Encode a Message Encode msgEncode = new Encode("We are using loops!!!!"); msgEncode.encodeMsg(); System.out.println("The endoded message is " + msgEncode.getEncodedMsg());

// Decode a Message String encodedMsg = msgEncode.getEncodedMsg(); // Create a Decode instance Decode msgDecode = new Decode(encodedMsg); msgDecode.decodeMsg(); System.out.println("The decoded message is " + msgDecode.getDecodedMsg());

System.out.println(" \t End of program!!!!"); } }

//******************************************************************** // Decode.java Author: Put Your Name Here // // The class will encode a string

//********************************************************************

import java.text.NumberFormat;

public class Decode { //Instance variables go here private String decodedMsg; private String encodedMsg; private int encodeKey = 5;

// Class constructor public Decode(String inStr) { encodedMsg = inStr; //Load the encoded message }

//----------------------------------------------------------------- // Decodes the message //----------------------------------------------------------------- public void decodeMsg() { //Add your code after this line!!!

}

//----------------------------------------------------------------- // Returns the encodedMsg //----------------------------------------------------------------- public String getDecodedMsg() { return decodedMsg; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!