Question: Java Please / / File: LessNaiveEncryption.java / / Author: / / / / Description: The skeleton of a program that uses split method / /

Java Please // File: LessNaiveEncryption.java // Author: //// Description: The skeleton of a program that uses split method // and a StringBuilder objects to reverse the letters of each word, // but which keeps the order of the words the same. For example: //// Input : 123ab 445 hello // Output: ba321544 olleh //// the required import statements import java.util.Scanner; public class LessNaiveEncryption public static void main(String[] args)// Setup a scanner object, and receive user's input Scanner keyboard = new Scanner(System.in); System.out.print("Provide a sentence to encrypt: "); String userInput = keyboard.nextLine(); // Step 1: use a split method on the String userInput. // The argument the split method should be the delimeter ""//// Step 1 can be completed in a single line of code. System.out.print("The encrypted sentence is: "); // Step 2a: Refer to the lecture slides, to see // how you can tokenize the sentence // that you've placed into userInput. You can use a // while loop, or a for loop. // split method will return an array of Strings (tokens).// Step 2b: For each token (word) that you extract from // the input sentences, build a StringBuilder object. We // learned in lecture that the StringBuilder Class has // many useful methods used to manipulate a String. // Perform a web search for "Java 8 API", and access the // oracle webpage. Click on the StringBuilder class // name in the navigation box on the left of the // screen, and look for a method that will reverse the // String field in the StringBuilder object that you've // created. // Step 2c: Use the method that you've found via the API, // to reverse the String field in your StringBuilder object, // and print that reverse String to the console. // Steps 2a through 2c can be completed with 5 lines of code. // If you used System.out.print when tokenizing your // String, the following command will output a final // blank line after the last output System.out.print(""); import java.util.Scanner; // File: NaiveEncryption.java // Author: Tatiana Harrison //// Description: An "encryption" program that does not // use the split nor StringBuilder classes, // but only the types of control structures that // you've learned in CS110. This same functionality // can be written in far fewer lines of code if // a split and StringBuilder were used. public class NaiveEncryption public static void main(String[] args)// setup a scanner object, and receive user's input Scanner keyboard = new Scanner(System.in); System.out.print("Provide an input sentence: "); String input = keyboard.nextLine(); System.out.print("The output sentence is : "); String intermediateWord =""; for (int i =0; i < input.length(); i++) if (input.substring(i, i +1).equals("")||(i +1)== input.length()) if ((i +1)== input.length()) intermediateWord += input.substring(i, i +1); for (int j = intermediateWord.length()-1; j >-1; j) System.out.print(intermediateWord.substring(j, j +1)); intermediateWord =""; System.out.print(""); else intermediateWord += input.substring(i, i +1); System.out.println(""); // File: OutrageousCalculations.java // Author: Tatiana Harrison // Explanation: A 'confusing' program, that lends itself // to analysis, using jGRASP's debugger. public class OutrageousCalculations // the main routine public static void main(String[] args) int calculatedNumber = performOutrageousCalculation(32); System.out.println("calculatedNumber: "+ calculatedNumber); int finalCal = performAnotherOutrageuosCalc(calculatedNumber); System.out.println("finalCal: "+ finalCal); // a method that has a complex for loop, with an embedded while loop public static int performOutrageousCalculation(int m) int someNumber = m; int anotherNumber =33; int j =3; for (int i =-2, k =4; i <9; i++, k -=3) i = i +1; j -= k; anotherNumber

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!