Question: From an old lab at a few weeks ago that i missed but want a better understanding of, due to my confusion of what my

From an old lab at a few weeks ago that i missed but want a better understanding of, due to my confusion of what my instructor was asking, comments on key parts is much appreciated.

Lab 2 Objectives:Familiarity with String Manipulation, Familiarity with Arrays

[Task 1] Write a JAVA class called PrintReverseArray which prompts user for the number of items in an array (a nonnegative integer), and saves it in an int variable called numItems. It then prompts user for the values of all the items and saves them in an int array called items. The program shall then print the contents of the array in a reverse form of [xn, xn-1, ..., x2, x1]. The program should have the main method.

Sample output of the program is Enter the number of items: 5 Enter the value of all items (separated by space): 3 2 5 6 9 The values are: [9, 6, 5, 2, 3]

[Task 2] Write a JAVA class called GradeStatistics which prompts user for the number of students in a class (a nonnegative integer) and saves it in an int variable called numStudents. It then prompts the user for the grade of each student (integer between 0 to 100) and saves them in an int array called grades. The program shall then compute and print the average (in double rounded to 2 decimal places), the minimum and the maximum (in int). The program should have the main method.

Sample output of the program is Enter the number of students: 5 Enter the grade for student 1: 98 Enter the grade for student 2: 78 Enter the grade for student 3: 78 Enter the grade for student 4: 87 Enter the grade for student 5: 76 The average is: 83.40 The minimum is: 76 The maximum is: 98

[Task 3] Write a JAVA class called EncryptString, which prompts user for a String, and prints an encrypted version of the String by extracting each character and replacing it with the next character. For example, a will be replaced by b, s will be replaced by t, z will be replaced by a and so on. The program should have the main method.

Sample output of the program is Enter a String: abcdef The encrypted version of the String "abcdef" is "bcdefg". You can use toLowerCase() or toUpperCase() to change the case of the input string. Make sure the string can also include space in it.

[Task 4] Caesar's Code is one of the simplest encryption techniques. Each letter in the plain text string is replaced by a letter some fixed number of position (n) down the alphabet cyclically. For example, if we pick n=3, then 'A' is replaced by 'D', 'B' by 'E', 'C' by 'F', ..., 'X' by 'A', ..., 'Z' by 'C'. Write a class called CaesarCode to convert plain text string into a cipher text, encoded using Caesar Code. CaesarCode constructor should two inputs: N: Indicates the number of positions to shift the input text by inputText: an input consisting of mix-case letters only

The program uses the following strategy for case sensitivity and special symbols Case Sensitivity: Maintain Case Special Symbols: Ignore

The class should have a function which outputs the cipher text encoded using Ceaser Code logic.

Hints 1. Use in.next().toUpperCase() to read an input string and convert it into uppercase to reduce the number of cases. 2. You can use a big nested-if with 26 cases ('A'-'Z'). But it is much better to consider 'A' to 'W' as one case; 'X', 'Y' and 'Z' as 3 separate cases. 3. Take note that char 'A' is represented as Unicode number 65 and char 'D' as 68. However, 'A' + 3 gives 68. This is because char + int is implicitly casted to int + int which returns an int value. To obtain a char value, you need to perform explicit type casting using (char)('A' + 3). Try printing ('A' + 3) with and without type casting.

Write a JAVA class called TestCeasarCode to test the Caesar's code class written earlier. This class should have the main method for CaesarCode. The program shall prompt user for an input text string consisting of mix-case letters only; call the class to convert the text to Ceaser Coded ciphertext, and print the ciphertext. It will then pass the output to the CaeserCode class with the correct value of N to test if the program is written correctly. Enter a plain text string: Testing$ The ciphertext string is: Whvwlqj // Now pass the ciphertext string again to the class CeaserCode, with the //correct value of N The plaintext string is: Testing

Note, you must figure out the correct value of N to pass to the class during the second task of converting cipher text to plain text.

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!