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
………………….. is the process of causing a system variable to conform to some desired value. Options Control feedback Design none of
frutty [35]
Control <span>is the process of causing a system variable to conform to some desired value. Options Control feedback Design none of the above</span>
4 0
3 years ago
which of the following is not a name of one of the central features of Facebook timeline activity log Graph Search for Daily New
Pani-rosa [81]
The correct answer is Graph Search for Daily News

This does not exist on Facebook, unlike the timeline and the activity log.
3 0
3 years ago
Can geico save me 15% or more on car insurance?
horsena [70]

Answer:

yes the ad says geico can save you 15% percent or more on car insurance

7 0
3 years ago
Read 2 more answers
Derek is working at the help desk when he receives a call from a client about an issue with the company’s email. The customer is
never [62]

Answer:

Let the customer vent and then restart the conversation

Explanation:

It is best for Derek in this situation allow the customer say everything on his or her mind about the problems at hand. This will help Derek identify and understand the problems and fix them accordingly. However, he'd need to start the world all over again to achieve this.

Cheers

5 0
3 years ago
Cameron wants to impress the owner of the company. He creates a graph that shows the improved productivity at the company over t
Umnica [9.8K]
Point, line, or bar graph is what he would use

6 0
3 years ago
Read 2 more answers
Other questions:
  • ________ is used to store programs and instructions that are automatically loaded when the computer is turned on.
    14·1 answer
  • write an application to presell a limited number of cinema tickets. each buyer can buy as many as 4 tickets. No more than 100 ti
    8·1 answer
  • ____ port is a connection in which eight data lines transmit an entire byte of data at one moment in time.
    12·1 answer
  • Google Slides saves your work to Google Drive. PowerPoint has the option to save to OneDrive. Both of these solutions are in the
    9·1 answer
  • You want to drive traffic to a new landing page for a campaign, and want a web address that's short, easy to remember, trackable
    7·1 answer
  • What is netbeans and what is it for??
    9·1 answer
  • I need help with this plz question 2 and 3 asap
    7·1 answer
  • What subject did this person struggle in, "I ain't never gonna nead to no this stuff."
    11·1 answer
  • What is used to accurately position objects on the slide using a single horizontal and vertical line that intersects in the cent
    12·2 answers
  • How to execute python code in command prompt *window*?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!