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
Helen [10]
3 years ago
13

Write a program called telephone.java that prompts the user to enter their phone number using the specific format: (xxx) xxx-xxx

x. The program should check whether the input entered is valid. The program must also check for the parenthesis () for the area code (the first three numbers). Example: (702)892-0516 would be correct but 702-892-0516 would not be correct. Example: Enter your phone number: 702-908-1333. 702-908-1333 is a NOT a valid phone number as there are no parenthesis (). Another example: Enter your phone number: (70 –290-8133 (70—290-8133 is NOT a valid phone number. If the entered telephone number is valid the program should return a statement that says the phone number is valid.
Computers and Technology
1 answer:
djverab [1.8K]3 years ago
8 0

Answer:

Following are the program in the Java Programming Language.

//import package scanner class

import java.util.Scanner;

//define class

public class telephone {

//define main method

public static void main(String[] args) {

//set object of the scanner class

Scanner sc = new Scanner(System.in);

//print message

System.out.println("Enter tele-phone no. using this format: (xxx)xxx-xxxx: ");

//get input from the user

String phn = sc.next();

//check length of phone number is equal to 13

if(phn.length() == 13) {

//check phone no. containing parentheses

if(phn.charAt(0) == '(' && phn.charAt(4)==')' && phn.charAt(8) == '-') {

//initializing the values

String num1 = phn.substring(1,4);

String num2 = phn.substring(5,8);

String num3 = phn.substring(9);

//check the following input is numeric or not

if(num1.matches("[0-9]+") && num2.matches("[0-9]+")&& num3.matches("[0-9]+")) {

//then, print valid message

System.out.println("Given phone number is valid");

}

//otherwise

else {

//print invalid message

System.out.println("Given phone number is invalid");

}

}

//otherwise

else {

//print invalid message

System.out.println("Given phone number is invalid");

}

}

//otherwise

else {

//print invalid message

System.out.println("Given phone number is invalid");

}

}

}

Explanation:

Following are the desciption of the program

  • Declared a class telephone
  • Read a input phone number in phn variable of string type.

Check the following condition of phone number

  •  if "phn"=="13" then it check for the parenthesis and number is valid otherwise phn number is invalid .
You might be interested in
A resistor bank is connected to a controller with conductor insulation rated 75 °C. The resistors are not used in conjunction wi
irina [24]

Explanation:

This means that it requires a disconnecting means for each motor, and it must be located in sight from the motor location and the driven machinery location.

Multiply the FLC of the largest motor by 125%.

Add up the FLCs of the other motors.

Multiply the continuous non-motor loads by 125%.

Add up all of the above to the total of the non-continuous loads.

3 0
3 years ago
How do i build a supercomputer.?
stira [4]
You will need one head node, at least a dozen identical compute nodes, an Ethernet switch, a power distribution unit, and a rack. Determine the electrical demand, cooling and space required. Also decide on what IP address you want for your private networks, what to name the nodes, what software packages you want installed, and what technology you want to provide the parallel computing capabilities
3 0
3 years ago
To achieve the maximum confidentiality and integrity found in a completely secure information system would require that the syst
fgiga [73]

Answer:

The answer is "Option a".

Explanation:

Privacy is a set of rules, which limiting access to the data, and integrity ensures impartiality, accuracy, and reliability is assured to ensure, which authorized persons can have secure access to the data.

The system needs no access for everyone to achieve its secrecy and integrity contained in a completely safe data system, that's why the given statement is "true".

5 0
3 years ago
which tool in administrative tools should you open if you want to view messages to troubleshoot errors? a. resource monitor b. e
VikaD [51]

A tool in administrative tools which you should open if you want to view messages to troubleshoot errors is an: b. event viewer.

<h3>What is an operating system?</h3>

An operating system (OS) can be defined as a system software that's usually pre-installed on a computing device by the manufacturers, so as to manage random access memory (RAM), software programs, computer hardware and all user processes.

<h3>What is an event viewer?</h3>

An event viewer can be defined as an administrative tool that is found in all versions of Windows Operating System (OS) which is designed and developed to enable administrators and end users in viewing the event logs of software application and system messages such as errors on a local or remote machine.

In this context, we can reasonably infer and logically deduce that an event viewer is a tool in administrative tools which you should open if you want to view messages to troubleshoot errors.

Read more on event viewer here: brainly.com/question/14166392

#SPJ1

4 0
1 year ago
Name at least TWO kinds of gaming experiences that are possible with these new control devices but were not possible on original
Pie

Yes the ansewer is c bc you can look it up!


6 0
2 years ago
Other questions:
  • ___ are files of related records organized according to logical systems and stored on computer-accessible media.
    5·1 answer
  • In addition to the ping command, what other command is useful in displaying network delay and breaks in the path to the destinat
    5·2 answers
  • Why would an IT technician ever have to change out a computer’s motherboard?
    5·2 answers
  • The company where Derek works has tasked him with setting up and securing a SOHO router. He wants to make sure the wireless netw
    11·1 answer
  • 11111 Power 2 sovle ​
    14·1 answer
  • Users can customize their Windows device by going to the Control Panel under __________.
    15·2 answers
  • A Consider the following method definition. The method printAllCharacters is intended to print out every character in str, start
    11·1 answer
  • The most widely used computer device​
    6·2 answers
  • In order to get the maximum functionality out of a device that is plugged in, a user should download the specific ___ for that d
    10·2 answers
  • Enterprise storage systems typically use fast Fibre Channel or ____ connections and are scalable so more hard drives can be adde
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!