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
A network administrator is configuring an ACL with the command access-list 10 permit 172.16.32.0 0.0.15.255. Which IPv4 address
lord [1]

Answer:

For this wild card mask 0.0.15.255 the ACE IP address will be 172.16.47.254

Explanation:

ACL is the access control list that is used to enlist the ip addresses that allowed or restricted to access the network. ACE is an IP address from the list ACL that has all rules and regulations related to access of network. The ACE could be in the range of IP address in ACL. ACL can be calculated with the help of initial IP address adding with wild card mask.

So

Initial IP address is = 172.16.32.0

Wild card mask =0.0.15.255

by adding above values we can find the last IP address of ACL.

after addition

Final IP address is = 172.16.47.255

The options that are available with question, Only option between the range is  172.16.47.254. So we can say that This is the only ACE IP address in options.

7 0
3 years ago
Which of the following groups would an animal with an exoskeleton, segmented body, and jointed appendages belong to???
Annette [7]
All arthropods have exoskeletons, like insects, spiders and crustaceans.
7 0
3 years ago
Read 2 more answers
Which social networking site became a gaming platform after 2009
PtichkaEL [24]

Answer:

Should be Hi5

have good day

3 0
3 years ago
Which early modernism trend in art focused on prehistoric or exotic cultures? primitivism expressionism impressionism total seri
AleksAgata [21]

Actually it's Primitivism

3 0
3 years ago
How do I persuade my parents to allow me to have social media? I will be 15 in a week or so, so I am old enough. I'm pulling my
Flauer [41]

Answer:

my explanation is above my comment :)

Explanation:

6 0
3 years ago
Other questions:
  • HELP AS SOON IS A UNIT TEST WILL GIVE BRAINLIEST
    9·2 answers
  • NEED THIS NOW PLEASE!!!! (I AM NOT JOKING I HAVE TO SUBMIT IN 5 MINUTES)
    13·2 answers
  • What content is important to include in your webpage?
    9·1 answer
  • Which one of these tasks is part of the pre-production phase of game development?
    11·2 answers
  • Where in an email would u find information about the action requirements​
    9·1 answer
  • Select the correct answer from each drop-down menu. Look at Marta's email signature and fill in the missing elements. Marta D'Ab
    14·2 answers
  • How do u know when a website doesnt like u?
    11·1 answer
  • How do you close a file?
    12·2 answers
  • How do I get the bot token for discord? (scripting etc)
    5·1 answer
  • the first thing to do when your computer gives you an error message is A restart the computer B press the F2 key C write down th
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!