Each number button on a telephone is assigned to different characters as shown below: Note: If...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Each number button on a telephone is assigned to different characters as shown below: Note: If you cannot see the following paragraph, set your browser encoding to Auto-select View, Encoding, Auto-Select 2 (ABC) 3 (DEF) 4 (G H I) 5 (JKL) 6 (M NO) 7 (P Q R S) 8 (TUV) 9 WXYZ For example the number 604 247 5463 can better be remembered as word (604) AIRLINE (refer to above table). note that each phone number can be represented as 604 xxxxxxx. What to do: Part 1: 1. You are to read telephone numbers from file telephone.txt and find match for the telephone numbers from a list of the words. 2. Skip the first part of the numbers (604). You are going to match the second part of the phone numbers XXXXXXX. 3. Each phone number is consist of 7 digits (exclude 604). Check the list of the words from word_list.txt file, and find words with length equal to 7 for the phone numbers. for example the number 604 2475463 matches with word AIRLINE. 4. find all matched words. 1 import java.io.FileNotFoundException; 2 import java.io.FileReader; 3 import java.io.FileWriter; 4 import java.io.IOException; 5 import java.io.File; 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 n 2 3 4 45 46 47 48 45 42 43 44 49 50 import java.io. BufferedWriter; public class Lab11 { 51 52 } public static void main(String[] args) { try { File file = new File("C:\CPSC1150\Lab11\Telephone.txt"); FileReader filereader = new FileReader(file); int ch; while ((ch = filereader.read()) != -1) { System.out.print((char) ch); } } } else { Filereader.close(); System.out.println("not found"); }catch (FileNotFoundException e) { System.out.println(e); } catch (IOException e) { System.out.println(e); } } try { File file = new File("C:\CPSC1150\Lab11\result.txt"); if (checkBeforeWritefile(file)) { FileWriter fileWriter = new FileWriter (file); filewriter.write(number); filewriter.close(); } else { System.out.println("can't write"); } catch (IOException e) { System.out.println(e); } public static boolean checkBeforeWritefile(File file) if (file.exists()) { if (file.isFile() && file.canwrite()) { return true; return false; } public static String number () telephone.txt - XE JE 604 2475463 604 2232532 (E) (0) (V) (H) 604 2332669 604 2692333 604 3352684 604 3282695 604 3692646 604 4273297 604 4894853 604 5386453 604 6266332 604 7695878 604 7293647 604 7862867 604 8432263 604 9272695 604 2782842 604 2277666 604 2337626 604 2682437 604 2263727 604 4263253 604 5865437 604 6335625 604 6624537 604 6878273 604 6877353 604 7296337 Part 2: 5. Each 7 digits of a phone number can also be represented by two groups of numbers, 3 and 4 digits, such as xxx XXXX. 6. Find all matches of the first part xxx (3 digits) with all words with 3 characters. 7. Find all matches of the second part xxxx (4 digits) with all words with 4 characters. Part 3: 8. Save all phone numbers and matched words (7, 3, and 4 digits) in file result.txt. Part of the file is shown below: TEL: 2475463 2475463: AIRLINE 247: AHR 247: AHS 247 : AIR 247 : AIS 247 : BIR 247 : BIS 5463: KIME 5463: KIND 5463: LIME 5463: LIND 5463 : LINE TEL: 2232532 223: ABE 223: ACE 223 : BAD 223 : BAE 223: CAD Each number button on a telephone is assigned to different characters as shown below: Note: If you cannot see the following paragraph, set your browser encoding to Auto-select View, Encoding, Auto-Select 2 (ABC) 3 (DEF) 4 (G H I) 5 (JKL) 6 (M NO) 7 (P Q R S) 8 (TUV) 9 WXYZ For example the number 604 247 5463 can better be remembered as word (604) AIRLINE (refer to above table). note that each phone number can be represented as 604 xxxxxxx. What to do: Part 1: 1. You are to read telephone numbers from file telephone.txt and find match for the telephone numbers from a list of the words. 2. Skip the first part of the numbers (604). You are going to match the second part of the phone numbers XXXXXXX. 3. Each phone number is consist of 7 digits (exclude 604). Check the list of the words from word_list.txt file, and find words with length equal to 7 for the phone numbers. for example the number 604 2475463 matches with word AIRLINE. 4. find all matched words. 1 import java.io.FileNotFoundException; 2 import java.io.FileReader; 3 import java.io.FileWriter; 4 import java.io.IOException; 5 import java.io.File; 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 n 2 3 4 45 46 47 48 45 42 43 44 49 50 import java.io. BufferedWriter; public class Lab11 { 51 52 } public static void main(String[] args) { try { File file = new File("C:\CPSC1150\Lab11\Telephone.txt"); FileReader filereader = new FileReader(file); int ch; while ((ch = filereader.read()) != -1) { System.out.print((char) ch); } } } else { Filereader.close(); System.out.println("not found"); }catch (FileNotFoundException e) { System.out.println(e); } catch (IOException e) { System.out.println(e); } } try { File file = new File("C:\CPSC1150\Lab11\result.txt"); if (checkBeforeWritefile(file)) { FileWriter fileWriter = new FileWriter (file); filewriter.write(number); filewriter.close(); } else { System.out.println("can't write"); } catch (IOException e) { System.out.println(e); } public static boolean checkBeforeWritefile(File file) if (file.exists()) { if (file.isFile() && file.canwrite()) { return true; return false; } public static String number () telephone.txt - XE JE 604 2475463 604 2232532 (E) (0) (V) (H) 604 2332669 604 2692333 604 3352684 604 3282695 604 3692646 604 4273297 604 4894853 604 5386453 604 6266332 604 7695878 604 7293647 604 7862867 604 8432263 604 9272695 604 2782842 604 2277666 604 2337626 604 2682437 604 2263727 604 4263253 604 5865437 604 6335625 604 6624537 604 6878273 604 6877353 604 7296337 Part 2: 5. Each 7 digits of a phone number can also be represented by two groups of numbers, 3 and 4 digits, such as xxx XXXX. 6. Find all matches of the first part xxx (3 digits) with all words with 3 characters. 7. Find all matches of the second part xxxx (4 digits) with all words with 4 characters. Part 3: 8. Save all phone numbers and matched words (7, 3, and 4 digits) in file result.txt. Part of the file is shown below: TEL: 2475463 2475463: AIRLINE 247: AHR 247: AHS 247 : AIR 247 : AIS 247 : BIR 247 : BIS 5463: KIME 5463: KIND 5463: LIME 5463: LIND 5463 : LINE TEL: 2232532 223: ABE 223: ACE 223 : BAD 223 : BAE 223: CAD
Expert Answer:
Answer rating: 100% (QA)
Source Code TelephoneStringOperationsjava import javaioFile import javaioFileWriter import javaioIOException import javautilArrayList Java program to ... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
Which statements are true about the requires directive? (Choose two.) A. Changing it to a requires direct directive is always allowed. B. Changing it to a requires direct directive is never allowed....
-
From the official website of the 2013 Los Angeles Dodgers major league baseball team, we found that there were five active players on roster available to play outfield. Assuming that these five...
-
A normal subgroup Hof a group G is said to be a direct factor (direct summand if G is additive abelian) if there exists a (normal) subgroup K of G such that G = H X K. (a) If H is a direct factor of...
-
Fantastic Sams and Defendants PSTEVO, LLC and Jeremy Baker entered into a franchise agreement pursuant to which Fantastic Sams granted PSTEVO a franchise to operate a Fantastic Sams Salon. According...
-
a. Assume that Caro-Life wants to maximize the average sales potential of its ten offices. Where should it locate offices and what is the population and geographic area associated with each office?...
-
3. Write a test program which has a static method that takes a shape argument and displays information about it (its radius, its area and volume, if applicable). Writing this to display information...
-
Ivanhoe Company ended its fiscal year on July 31, 2020. The company's adjusted trial balance as of the end of its fiscal year is as follows. Ivanhoe Company Adjusted Trial Balance July 31, 2020 No....
-
A firm currently has no debt. Its' required return on stock is based on an unlevered beta of 0.8, a risk free rate of 4% and a market risk premium of 5%. EBIT (taxable income if an all equity firm) =...
-
What will a deposit of RM7,500 left in the bank be worth under the following conditions: a) Left for nine years at 7% simple interest? b) Left for six years at 6% compounded semiannually? c) Left for...
-
AVIATION SAFETY - (GA Aircraft and Data Recorders) 1. Can accident information be obtained from any personal handheld digital device found at the scene? Explain and provide an example. And cite one...
-
On April 22, 2020 you observed the following S&P/TSX index futures quotes: S&P/TSX 60 index futures:April 22, 2020. ( multiplier M = $100 ) Spot index value1850 June futures contract1820 September...
-
Explain what is meant by the required rate of return and include an example.
-
Reading 3: S inha, Ashish, Prakash Bagri, Kiran Pedada and Rajendra Srivastava (2022), "E commerce Disrupted: Is Social Ecommerce the Future of Retail," A cceptance, Managementand Business Review ....
-
1- On the date of 1/1/2020, Trader Ahmed started his business with a capital of 24,000 dinars, provided as follows: Goods 8,000 dinars, a box of 10,000 dinars, a bank 6,000 dinars. 2 - On 2/1/2020, a...
-
Why is disclosure of depreciation or amortization methods and rates so important?
-
a. Wilson filed his individual tax return on the original due date, but failed to pay $700 in taxes that were due with the return. If Wilson pays the taxes exactly 2 months late, calculate the amount...
-
Your supervisor has asked you to research the following situation concerning Owen and Lisa Cordoncillo. Owen and Lisa are brother and sister. In May 2012, Owen and Lisa exchange business pickup...
-
While preparing Massie Miller's 2012 Schedule A, you review the following list of possible charitable deductions provided by Massie: Cash contribution to a family whose house burned...
-
A 17 g audio compact disk has a diameter of 12 cm. The disk spins under a laser that reads encoded data. The first track to be read is 2.3 cm from the axis; as the disk plays, the laser scans tracks...
-
A spin bike is an indoor bike that is designed to duplicate the feeling of regular road cycling. A typical spin bike has a very heavy flywheel. A friction pad or other brake provides damping that...
-
A trap-jaw ant has mandibles that can snap shut with some force, as you might expect from its name. The formidable snap is good for more than capturing prey. When an ant snaps its jaws against the...
Study smarter with the SolutionInn App