Question: Use a method to decode. You should pass the numeric key and the message string to the method and return the decoded string from the
Use a method to decode. You should pass the numeric key and the message string to the method and return the decoded string from the method to main. Project data will be in two data files, first will be data6a.txt with the offset value and the second will be data6b.txt that will have several lines of codes. The ONLY input and output will be from the main method. The ONLY manipulation of the coded message will be in the decode method.
Write a method to decode secret messages, using the numeric key and a coded message. The numeric key is the positive integer value that was added to the ascii characters numeric value to get the coded message. You should subtract that value to decode(remember to keep the character values in the range of a-z have numeric value between 97(a) and 122(z). If a character is outside after conversion, force that character back into the range). Any characters that do not start in that range should just be passed straight through, for instance the space(character = 32). All letters will be lower-case, punctuation and spaces should be passed straight through. Write a program to use the method by using the numeric key from data6a.txt and processing each line in the data file, data6b.txt to be converted from the garbled characters into readable characters.
Data a is:
13
data b is:
gur bayl gvzr crbcyr qvfyvxr tbffvc vf jura lbh tbffvc nobhg gurz
bayl gur zrqvbper ner nyjnlf ng gurve orfg
lbh'er arire jebat gb qb gur evtug guvat
ernyvgl vf gur zheqre bs n ornhgvshy gurbel ol n tnat bs htyl snpgf
v'z n terng oryvrire va yhpx, v svaq gur uneqre v jbex gur zber v unir bs vg
vg'f arire whfg n tnzr jura lbh'er jvaavat
rirelguvat vf shaal nf ybat nf vg vf unccravat gb fbzrobql ryfr
lbh pna arire haqrerfgvzngr gur fghcvqvgl bs
gur trareny choyvp gur sbby qbgu guvax ur vf jvfr, ohg gur jvfr zna xabjf uvzfrys gb or n sbby
arire pbashfr zbirzrag jvgu npgvba
lbh xabj rirelobql vf vtabenag, bayl ba qvssrerag fhowrpgf
gb ree vf uhzna, ohg gb ernyyl sbhy guvatf hc erdhverf n pbzchgre
jvfqbz vf jung'f yrsg nsgre jr'ir eha bhg bs crefbany bcvavbaf
My questions is what would my main method be and what would my decoded method be and what should my sample output look like? I have done something similar to this in the past. The code I have used for the similar on is:
import java.io.*; import java.util.Scanner; public class project05 { public static void main(String[] args) throws StringIndexOutOfBoundsException, IOException { String line=""; Scanner filescanner = null; BufferedWriter filewriter= null; try { filescanner = new Scanner(new File("dataSample5a.txt")); filewriter = new BufferedWriter(new FileWriter("dataSample5b.txt")); int a = Integer.parseInt(filescanner.nextLine()) % 26; System.out.printf("Spring 2017 Project 5 Due 3/13/17 by Jacob Oberle "); filewriter.write("Spring 2017 Project 5 Due 3/13/17 by Jacob Oberle "); while (filescanner.hasNextLine()) { line = filescanner.nextLine(); System.out.printf("the code is - *%s", line); filewriter.write("dhe code is - * "); filewriter.write(line); System.out.printf(" decoded is -*"); filewriter.write(" decoded is -*"); for (int i = 0; i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
