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]
2 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]2 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
Maxwell says three things Level Two Leaders do well are:
IRINA_888 [86]

Answer:

true

Explanation:

3 0
3 years ago
1. Felipe looks over his presentation, and he notices that some of his words are written in bold and some are written in italic.
romanna [79]
 <span>Felipe looks over his presentation, and he notices that some of his words are written in bold and some are written in italic.</span>His ability to remember these differences is an example of Retroactive encoding. Even though you didn't share the options, I am pretty sure this one will help!

4 0
2 years ago
A2 Suggest why the Petri dish and agar jelly needed to be sterile.​
Mashcka [7]

A Petri dish (Petri plate) is a shallow cylindrical glass lidded dish that is typically used to culture microorganisms (agar plates). There are glass and plastic Petri dishes, and both can be sterilized (using an autoclave) and re-used. Before being used for culture purposes, it is important to ensure that the Petri dish is not only clean, but also sterile. This helps prevent the contamination of the new culture.Agar is a polymer made up of various sub-units of galactose and various species of red algae. Although it has other uses including culinary and dentistry, agar plays an important role in microbiology as culture media for a variety of microorganisms.As compared to some of the other alternatives like gelatin, agar has a number of advantages which include:Cannot be easily degraded by microorganism Stronger Firmer than gelatin

6 0
2 years ago
In 1928 what film was the first all talking feature
goblinko [34]

Lights of New York was the 1928 what film was the first all talking feature.

8 0
3 years ago
Alice has 1/5 as many miniature cars as Sylvester has slyvester has 35 miniature cats how many miniature cars dose Alice have
garik1379 [7]
Alice has 7 miniature cars
5 0
3 years ago
Other questions:
  • In an airline reservation system, on entering the flight number, the flight schedule and the flight status are displayed. In thi
    13·2 answers
  • How do you read a column
    8·1 answer
  • Which protocol is used by the client for microsoft networks and file and printer sharing for microsoft networks to communicate w
    10·1 answer
  • Which scenario depicts an ethical workplace practice by a business owner
    15·2 answers
  • Write an expression that will print "in high school" if the value of user_grade is between 9 and 12 (inclusive). Sample output w
    12·1 answer
  • What is the description of a computer ram?
    7·1 answer
  • Name the sections of an instruction.
    15·1 answer
  • Count the number of words in the string. A word is one or more non-blank characters separated by one or more blanks. My suggesti
    13·1 answer
  • Computer crimes are a big concern since the creation of innovative technological advances; which is/are examples of computer cri
    13·2 answers
  • The operating system (OS) of an information system contains the software that executes the critical functions of the information
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!