JAVA PROGRAM(LL)+MINDTAP (1 TERM) V2.0
JAVA PROGRAM(LL)+MINDTAP (1 TERM) V2.0
9th Edition
ISBN: 9780357616673
Author: FARRELL
Publisher: CENGAGE L
bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 7, Problem 9PE

Explanation of Solution

Program:

File name: “PhoneNumberFormat.java

//Import necessary header files

import java.util.Scanner;

//Define a class named PhoneNumberFormat

public class PhoneNumberFormat

{

    //Define main method

    public static void main(String args[])

    {

        //Create an object for the Scanner class

        Scanner scanner = new Scanner(System.in);

        //do..while loop

        do

        {

            //Prompt the user to enter a Phone Number

            System.out.print("\nEnter the Phone Number: ");

            String textPhone = scanner.nextLine();

 /*Continue to accept the user input until the user enters 999*/

            if (textPhone.contains("999"))

                break;

            //If the user enters a ten-digit phone number

            if (textPhone.matches("[0-9]+") && textPhone.length() == 10)

            {

                //Print the result

                System...

Blurred answer
Students have asked these similar questions
DatacommunicationData = 1 1 0 0 1 0 0 1 0 1 1 1 1 0 0a) how many bıts can be detected and corrected by this coding why prove?b)what wıll be the decision of the reciever if it recieve the following codewords why?
pattern recognitionPCA algor'thm
Consider the following program: LOAD AC, IMMEDIATE(30)                                                     ADD AC, REGISTER(R1)                                                     STORE AC, MEMORY(20) Given that the value of R1 is 50, determine the value stored at memory address 20 after the program is executed. Provide an explanation to support your answer.
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
  • Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C - File I/O; Author: Tutorials Point (India) Ltd.;https://www.youtube.com/watch?v=cEfuwpbGi1k;License: Standard YouTube License, CC-BY
file handling functions in c | fprintf, fscanf, fread, fwrite |; Author: Education 4u;https://www.youtube.com/watch?v=aqeXS1bJihA;License: Standard Youtube License