Texting Translator

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

(JAVA)

AVOID USING BREAKS, CATCH, AND CASE!!!!

Texting Translator

  • For this assignment, we are going to work with adding and removing data from arrays, linear search, and File I/O.
  • This program will act as a texting to English converter
  • This program will read a file containing a list of abbreviations used in texting and another file with their English translations.
  • The abbreviations and translations need to be stored in two separate but parallel arrays (Links to an external site.).
  • Open up two new text files inside of Eclipse:
  • Name these text files abbreviations.txt and translations.txt

Copy and paste the following list of names into your abbreviations.txt file:

4
cu
ikr
k
l8
l8r
lmk
m8
nvm
r
smh
u
ur
wu

Copy and paste the following list of translations into your translations.txt file:

for
see you
I know right?
okay
late
later
let me know
mate
never mind
are
shaking my head
you
you are
what's up?

  •  

Starter Code

/**

* @author

* @author

* CIS 36B

*/

import java.util.Scanner;

import java.io.File;

import java.io.IOException;

import java.io.PrintWriter;

 

public class TextTrans {

   

     public static void main(String[] args) throws IOException {

      

          Scanner input = new Scanner(System.in);

          System.out.println("Welcome to the Texting Translator!");

 

          System.out.println("\nGoodbye!");     

     }

 

   

     /**

       * Inserts a String element into an array at a specified index

       * @param array the list of String values

       * @param numElements the current number of elements stored

       * @indexToInsert the location in the array to insert the new element

       * @param newValue the new String value to insert in the array

       */

  

     public static void insert(String array[], int numElements,

              int indexToInsert, String newValue) {

      

     }

   

     /**

       * Removes a String element from an array at a specified index

       * @param array the list of String values

       * @param numElements the current number of elements stored

       * @param indexToRemove where in the array to remove the element

       */

   

     public static void remove(String array[], int numElements, int indexToRemove) {

         return;

     }

 

     /**

       * Prints parallel arrays of Strings to a file  

       * @param names the list of abbreviations

       * @param translations the list of corresponding translations

       * @param numElements the current number of elements stored

       * @param file the file name

       */

     public static void printFile(String[] abbreviations, String[] translations,

               int numElements, String file) throws IOException {

         return;

     }

   

   /**

     * Searches for a specified String in a list

     * @param array the array of Strings

     * @param value the String to serach for

     * @param numElements the number of elements in the list

     * @return the index where value is located in the array

     */

   public static int linearSearch(String array[], String value, int numElements) {

        return -1;

   }

 

}



Sample Output


Welcome to the Texting Translator!

Below are the texting abbreviations:

0. 4
1. cu
2. ikr
3. k
4. l8
5. l8r
6. lmk
7. m8
8. nvm
9. r
10. smh
11. u
12. ur
13. wu

Please enter a menu option (A, R, S, X) below:

 

A. Add an Abbreviation
R. Remove an Abbreviation
S. Search for a Translation
X. Exit

Please enter your choice: A

Enter the abbreviation: rofl
Enter the position at which to add rofl: 10
Enter the translation of rofl: rolling on the floor laughing


Below are the texting abbreviations:

0. 4
1. cu
2. ikr
3. k
4. l8
5. l8r
6. lmk
7. m8
8. nvm
9. r
10. rofl
11. smh
12. u
13. ur
14. wu

Please enter a menu option (A, R, S, X) below:

A. Add an Abbreviation
R. Remove an Abbreviation
S. Search for a Translation
X. Exit

Please enter your choice: R

Please enter the abbreviation to remove: l8

Removing l8...
Is this correct (y/n): y

l8 has been removed.

Below are the texting abbreviations:

0. 4
1. cu
2. ikr
3. k
4. l8r
5. lmk
6. m8
7. nvm
8. r
9. rofl
10. smh
11. u
12. ur
13. wu

Please enter a menu option (A, R, S, X) below:

A. Add an Abbreviation
R. Remove an Abbreviation
S. Search for a Translation
X. Exit

Please enter your choice: S

Enter the abbreviation: u

The abbreviation "u" means: you

Below are the texting abbreviations:

0. 4
1. cu
2. ikr
3. k
4. l8r
5. lmk
6. m8
7. nvm
8. r
9. rofl
10. smh
11. u
12. ur
13. wu

Please enter a menu option (A, R, S, X) below:

A. Add an Abbreviation
R. Remove an Abbreviation
S. Search for a Translation
X. Exit

Please enter your choice: X

Enter the name of a file to write your abbreviations: output.txt

Goodbye!

Contents of corresponding output file (output.txt in my example - but user should specify the name):

0. 4: for

1. cu: see you

2. ikr: I know right?

3. k: okay

4. l8r: later

5. lmk: let me know

6. m8: mate

7. nvm: never mind

8. r: are

9. rofl: rolling on the floor laughing

10. smh: shaking my head

11. u: you

12. ur: you are

13. wu: what's up?

  • Note that the user should be able to enter any file name of their choice. It does not have to be output.txt.

  • Note that no error checking is required. You may assume that the user enters the inputs correctly.

Read the contents of each file and store them in a separate arrays, one array called
abbrevations and one array called translations.
You should declare arrays of length 150, and separately store information about the
current number of values stored inside of the two arrays.
Hint: you can use a variable to count how many values are in each file as you are
reading in the data, and use this information to save the number of values currently
stored in each array.
Next, you will need to write a menu-driven program to allow the user to complete 3
tasks:
o Add an Abbreviation
o Remove an Abbreviation
o Search for a Translation
o Exit
For the add menu option , the program should do the following:
o Prompt the user for an abbreviation and its transation to insert, and a
position in the arrays at which to insert.
o Call the insert method twice to insert the name and score into the
respective arrays at the indicated position (index).
• For the remove menu option , the program should do the following:
o Prompt the user for the abbreviation to remove.
o Next, call linearSearch to determine at which index in the array the
abbreviation is placed
Confirm that it has located the correct abbreviation in the array by
verifying the user wishes to remove the abbreviation.
o Finally, call the remove method to remove both the abbreviation from the
abbreviations array and the translation from the translations array
For the search for a translation menu option, the program should do the following:
o Prompt the user for the abbreviation.
o Next, call linearSearch to determine at which index in the array the
abbreviation is placed
o Print the translation that is located at that same index.
For the exit menu option , the program should do the following:
o Prompt the user to enter the name of a file in which to print the
abbreviations and translations
o call the printFile method passing in the name of the indicated file
To begin, copy and paste the starter code into a file called TextTrans.java
Make sure that you implement and call all of the methods whose signatures are
specified below
• Note that you made add any additional methods that you like to complete the
program
When your program is working correctly, upload it to Canvas.
Transcribed Image Text:Read the contents of each file and store them in a separate arrays, one array called abbrevations and one array called translations. You should declare arrays of length 150, and separately store information about the current number of values stored inside of the two arrays. Hint: you can use a variable to count how many values are in each file as you are reading in the data, and use this information to save the number of values currently stored in each array. Next, you will need to write a menu-driven program to allow the user to complete 3 tasks: o Add an Abbreviation o Remove an Abbreviation o Search for a Translation o Exit For the add menu option , the program should do the following: o Prompt the user for an abbreviation and its transation to insert, and a position in the arrays at which to insert. o Call the insert method twice to insert the name and score into the respective arrays at the indicated position (index). • For the remove menu option , the program should do the following: o Prompt the user for the abbreviation to remove. o Next, call linearSearch to determine at which index in the array the abbreviation is placed Confirm that it has located the correct abbreviation in the array by verifying the user wishes to remove the abbreviation. o Finally, call the remove method to remove both the abbreviation from the abbreviations array and the translation from the translations array For the search for a translation menu option, the program should do the following: o Prompt the user for the abbreviation. o Next, call linearSearch to determine at which index in the array the abbreviation is placed o Print the translation that is located at that same index. For the exit menu option , the program should do the following: o Prompt the user to enter the name of a file in which to print the abbreviations and translations o call the printFile method passing in the name of the indicated file To begin, copy and paste the starter code into a file called TextTrans.java Make sure that you implement and call all of the methods whose signatures are specified below • Note that you made add any additional methods that you like to complete the program When your program is working correctly, upload it to Canvas.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 12 images

Blurred answer
Knowledge Booster
Hyperlinks
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education