How many string s it should process between one and ten

Assignment Help Programming Languages
Reference no: EM131926691

Programming Assignment

Overview

Revisiting the ROT13 encryption program, you are going to break the previous version of the program into methods with this additional functionality:

• The program will ask how many String s it should process, between 1 and 10, and store those String s into an array for processing.

• The program will ask for a shifting factor between -25 and +25, which will determine the encryption/decryption shifting instead of the default shifting by 13 of the previous version of the program.

See descriptions of these additional methods later in the assignment for more information.

Assignment

Make sure you fix any issues that may have been present in that version of the assignment.

Public Methods the Program Must Provide

All methods must be implemented as named as as described in order for Web-CAT to be able to test and score them correctly.

Here are the seven methods you need to write in addition to your main () method for this program.

1. public static int getShift()

This method asks the user to enter a shift value between -25 and 25 inclusive, displays a conversion chart for the user to approve, and then returns the shift value only if they approve of the conversion chart that's been displayed. Data validation should occur on the value between -25 and 25.

2. public static void getSentences (String sentences [])

This method displays all of the elements of the array of String data that it receives, line by line (element by element).

4. public static char shiftLetter(char toConvert, int shift)

This method will shift uppercase letters A through Z shift positions upwards or downwards within the uppercase letters; e.g. shiftLetter('A', 27) returns 'B' . The same operation also applies for lowercase letters a through z ; e.g. shiftLetter('b', -3) returns 'y' . All other characters are returned unchanged; i.e. shiftLetter('!', 5) returns '!' .

5. public static String convertSentence (String sentence, int shift)

This method will do the actual conversion of a String of data to its encoded equivalent in 6-character chunks of data and return the new, encoded String . It should call on the shiftLetter() method to do the actual character conversion for each individual character. In other words, individual character conversion should not happen within this method. This method doesn't do any output.

6. public static void displayEncoded (String[] sentences, int shift)

This method will display in encoded format all of the elements of the array of String data that it receives. It will need to call on the method convertSentence() to convert each string before it displays it. Note that the original array should not be modified with encoded data.

7. public static void displayCombined (String[] sentences, int shift)

This method takes an array of String data and combines all of the String s into a single String that is then processed by the convertSentence() method. The method should essentially display the same results as the displayEncoded() method, except that there won't be separate lines of output but rather one large result instead.

Other String things

The only new thing you'll need to be able to do with a String is build a new String from scratch. You can do this by using the concatenation operation in Java, which uses the operator to append char or String data to an existing String.

Using a global private static Scanner

As with program #9, you will want to utilize a private static Scanner variable in this program. Refer back to that assignment for more information on how to implement this kind of Scanner.

Goals

• Repurpose and refactor code you've already written and enhance its functionality. It's possible you may need to rewrite portions of your existing codebase.

• Continue to refine your refactoring skills while adding additional functionality to an existing program.

• Implement a one-dimensional array of String data and practice passing that array to methods.

Class and File Naming

Name your class Encoder.

Points to Think About

• Depending on how you've implemented your code in the previous assignment, you may need to do a little more rewriting of your code as you compartmentalize different portions of the program in methods.

• One thing you may need to adjust is that in the previous program, you may have simply done output with each character as you encountered it and then output a space every 6 characters. For this program, you'll need to modify that code to build a instead of directly doing output.

• Notice as you implement each method that the methods perform small, well-defined tasks and that some of the methods end up calling other methods to help accomplish those tasks.

Testing Your Program

• Web-CAT expects to find all of the seven methods above plus your main () method when it compiles. To prevent errors and allow for testing earlier you can 'stub out' the methods. This usually involves writing the method signature and block and simply returning a dummy value such as 0 for numbers, false for booleans, '!' for char values, and "test" or some other short message for string return values. You can then write the logic and pass the tests on Web-CAT on a per-method basis, rather than all-or-nothing.

• Check out the sample runs at the end of the assignment for examples.

• Remember that the jGRASP Interactions tool is very useful for testing the individual methods without having to implement all of the supporting code. Directions are provided in the previous assignment for using this tool.

Reference no: EM131926691

Questions Cloud

Conduct practical assessment of your organisations resources : BSBSUS2O1 Participate in environmentally sustainable work practices - Conduct a practical assessment of your organisation's resources and practices.
What are these recommendations often referred to as : The National Institutes of Health have recommendations for the early hearing detection and intervention (EHDI)
Discuss about the supranational executive corps : Is a ‘‘supranational executive corps,'' consisting of cosmopolitan individuals of multiple nationalities who would be an asset wherever utilized.
Equivalent to the gymnosperm male cone : Which structure in the angiosperm flower is roughly equivalent to the gymnosperm male cone? Why?
How many string s it should process between one and ten : The program will ask how many String s it should process, between 1 and 10, and store those String s into an array for processing.
Find the unknown semi-annual yield on the security : It has a coupon rate of 2% which is paid semi-annually. The next coupon payment will be in exactly 6 months. The TIPs has 1 year to maturity.
What additional benefit is brought into expatriate selection : What additional benefit is brought into the expatriate selection and training process by adaptability screening? A manager with a current base salary.
Number of disadvantages compared to other animals : Humans as individuals have a number of disadvantages compared to other animals. For instance we are not very fast, strong, cannot see well in the dark
Determine the net after-tax cash flows over the project life : Determine the net after-tax cash flows over the project life. Compute the IRR for this investment. At MARR = 18%, is the project acceptable?

Reviews

Write a Review

Programming Languages Questions & Answers

  Network programming

From where does the template class derived from in network programming?(

  Write a procedure make-accumulator

Write a procedure (make-queue) that produces independent first-in-first-out queue objects, using a message-passing style.

  Write the function definition as a recursive search

Write the function definition as a recursive search, assuming an array-based implementation.

  Deck of cards programming class

Write a complete program using "ECLIPS" that implements the functionality of a deck of cards. In writing your program, use the provided DeckDriver and Card classes shown below. Write your own Deck class so that it works in conjunction with the two..

  Implement effective security training

What are the four target audiences that the companys new system security policy must reach and  Discuss a few of the 7 necessary steps to implement effective security training.

  Write program to perform arithmetic operations on fractions

Write a program that lets the user perform arithmetic operations on fractions. Fractions are of the form a/b, where a and b are integers and b is not equal to 0.

  Cloud computing significantly improve public sector it

Cloud computing can significantly improve public sector IT.A number of government agencies are adopting cloud technologies and are realizing considerable benefits. For instance, NASA Nebula,5 through a community cloud, gives researchers access to ..

  Create a windows form application project.

Add an Enter Friend button which will process the entries made in the textboxes; writing each entry to a file and an Exit button which will exit the application

  Write program to evaluate young worker-s earning

Write down a program to evaluate how much young worker will make before retiring at age 65. Request worker's name, age, and starting salary as input.

  Write a program that accepts ciphertext only

Write a program that accepts ciphertext only. The program finds the keys and decipher the message. To decipher the message use the program you wrote in Lab 1.

  Write a program that demonstrates hoe the classescollaborate

Write a program that demonstrates hoe the classescollaborate. To issue a parking ticket (generate a ParkingTicket object) if the car's time has expired.

  Implement a menu-driven program for a hardware store

Perform a sales transaction - allow several hardware items to be purchased Remove a sales transaction based on invoice number and Edit a sales transaction by changing the hardware item's barcode and/or quantity purchased

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd