1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Andrew [12]
3 years ago
10

Write an application that inputs a telephone number as a string in the form (555) 555-5555. The application should use String me

thod split to extract the area code as a token, the first three digits of the phone number as a token and the last four digits of the phone number as a token. The seven digits of the phone number should be concatenated into one string. Both the area code and the phone number should be printed. Remember that you will have to change deliminator characters during the tokenization process.
Computers and Technology
1 answer:
Scilla [17]3 years ago
8 0

Answer:

See explaination

Explanation:

// File: TelephoneNumber.java

import java.util.Scanner;

public class TelephoneNumber

{

public static void main(String[] args)

{

Scanner input = new Scanner(System.in);

String inputNumber;

String tokens1[];

String tokens2[];

String areaCode;

String firstThree;

String lastFour;

String allSeven;

String fullNumber;

/* input a telephone number as a string in the form (555) 555-5555BsAt4ube4GblQIAAAAASUVORK5CYII= */

System.out.print("Enter a telephone number as '(XXX) XXX-XXXX': ");

inputNumber = input.nextLine();

System.out.println();

/* use String method split */

tokens1 = inputNumber.split(" ");

/* extract the area code as a token */

areaCode = tokens1[0].substring(1, 4);

/* use String method split */

tokens2 = tokens1[1].split("-");

/* extract the first three digits of the phone number as a token */

firstThree = tokens2[0];

/* extract the last four digits of the phone number as a token */

lastFour = tokens2[1];

/* concatenate the seven digits of the phone number into one string */

allSeven = firstThree + lastFour;

/* concatenate both the area code and the seven digits of the phone number into one full string separated by one space */

fullNumber = areaCode + " " + allSeven;

/* print both the area code and the phone number */

System.out.println("Area code: " + areaCode);

System.out.println("Phone number: " + allSeven);

System.out.println("Full Phone number: " + fullNumber);

}

}

You might be interested in
Which two computer peripherals are connected to the computer through a port?
chubhunter [2.5K]
Most computer devices are connected to the computer through port
Keyboard through usb port
Printer through usb port
Hand point device through usb port
Also computer equipped with LPT port for printers and COM port for additional devices like external modems e.t.c
7 0
3 years ago
When did economies begin?
Pavlova-9 [17]
They began in ancient times the babylons started trading
6 0
3 years ago
Read 2 more answers
What are examples of people who own the copyrights of their property? Check all that apply.
jolli1 [7]
"Nevaeh thinks of a name for her new company", "Alexis thinks of an idea for a new product" and "Josiah writes a poem" are open to copyright because they can claim that their work is original and cannot be reproduced without their consent. 
3 0
3 years ago
Read 2 more answers
The processor in Q1 above is converted into an 8-stage pipeline, similar to the one discussed on slide 8 of lecture 16. It takes
Nadusha1986 [10]

Answer:

1000/125 billion instructions per second.

Explanation:

All the stages take 125ps and latch time was outlooked.

The clock speed would be the highest stage time in all 5 stages. Here all are same clock speed it would be 125ps only.

throughput = 1/cycle time so ⇒ 1/125 instructions/ps

Since we want it in billion instructions per second so we have to multiply with 10⁻⁹ /10⁻¹² then the result is 1000/125 billion instructions per second.

3 0
2 years ago
Matt goes to an Internet café and tries to access his emails. The email client asks Matt to enter his email address along with t
Radda [10]

Answer:

acknowledging

Explanation:

it has to be d

6 0
3 years ago
Other questions:
  • Define a function that takes two arguments: a string called strText and a number called intNumber. This function will use a repe
    12·2 answers
  • im in honors comupter science and one of my questions is evaluate 18% 7 does anyone know how to answer that
    6·1 answer
  • Implement a Python function with the signature Transfer(S, T) that transfers all elements from the ArrayStack instance S onto th
    13·1 answer
  • Intranets: a. are based on mainframe technology. b. provide the platform on which a firm builds its information systems. c. are
    11·1 answer
  • Write a while loop that adds the first 100 numbers (from 1 to 100) together. To do so, use a while loop that continues while the
    12·2 answers
  • __________ are the first line of defense against unsafe drivers.
    5·1 answer
  • PLEASE HELP. I’ll mark you BRAINLIST <br> Please read the comment under this question
    9·1 answer
  • What would you do if you experienced academic frustrations in school? Check all that apply.
    15·2 answers
  • When does the following while-loop stop running?
    10·1 answer
  • In Subtractive empathy, the counselor responses gives back less (or distorts) than what the client has said. slightly add someth
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!