Write in Java:
Given a long integer representing a 10-digit phone number, output the area code, prefix, and line number using the format (800) 555-1212.

Ex: If the input is:
8005551212

the output is:
(800) 555-1212

Hint: Use % to get the desired rightmost digits. Ex: The rightmost 2 digits of 572 is gotten by 572 % 100, which is 72.

Hint: Use / to shift right by the desired amount. Ex: Shifting 572 right by 2 digits is done by 572 / 100, which yields 5. (Recall integer division discards the fraction).

For simplicity, assume any part starts with a non-zero digit. So 0119998888 is not allowed.

LabProgram.java:

import java.util.Scanner;

public class LabProgram {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
long phoneNumber;
// Add more variables as needed

phoneNumber = scnr.nextLong();

/* Type your code here. */
}
}

Answers

Answer 1

import java.util.Scanner;

public class LabProgram {

public static void main(String[] args) {

   Scanner scnr = new Scanner(System.in);

   long phoneNumber;

   phoneNumber = scnr.nextLong();

   long areaCode =  phoneNumber/10000000;

   long prefix = (phoneNumber/10000)%1000;

   long lineNumber = phoneNumber%10000;

   System.out.println("("+areaCode+")"+prefix+"-"+lineNumber);

}

}

I hope this helps!


Related Questions

Which of the following statements is true concerning the Internet of Things (IoT)? Wearable technologies are the only devices that currently connect to the Internet of Things. IoT is not affecting many businesses and the products they offer. Growth is expected to slow down over the next five years. IoT technology is relatively new and is expanding exponentially.

Answers

Answer:

i was looking and i think the answer would be growth slowing down but i might be wrong

Explanation:

Which of the following statements is true concerning the Internet of Things IoT is that the technology is relatively new and is expanding exponentially.

The IoT is regarded as a large network of connected things and individual. They collect and share data about the way they are used and about the environment around them.

It is aimed to connect all potential objects to interact each other on the internet to provide secure and a more comfort life for people.

The future of IoT has the prediction to be limitless with great advances and the industrial internet will be accelerated.

Conclusively, the Internet of Things (IoT) connect the world together.

Learn more from

https://brainly.com/question/14397947

Create a conditional expression that evaluates to string "negative" if user_val is less than 0, and "nonnegative" otherwise. Sample output with input: -9 -9 is negative

Answers

The conditional expression that evaluates to string "negative" if user_val is less than 0, and "nonnegative" otherwise is in explanation part.

What is conditional expression?

The ternary conditional operator is a ternary operator in computer programming that is part of the syntax for chied conditional expressions in several programming languages.

Here is the conditional expression in Python:

user_val = -9

result = "negative" if user_val < 0 else "nonnegative"

print(f"{user_val} is {result}")

In this code, the if-else conditional statement is used to check whether user_val is less than 0. If it is, the string "negative" is assigned to the result variable.

Thus, the string "nonnegative" is assigned to result. Finally, the print statement is used to display the output.

For more details regarding programming, visit:

https://brainly.com/question/11023419

#SPJ9

2. Discuss the advantages and disadvantages of using the Symbolic Math Toolbox to generate LTI transfer functions.

Answers

Symbolic Math Toolbox is important or organizing and visualizing the dataset.

What is Symbolic Math Toolbox?

It is a toolbox that provides the functions for solving equations, plotting graphs, and manipulating specific math equations.

This toolbox can help run and share some math code as well as different computations.

The advantages of the toolbox include,

It helps summarizes large data sets using frequency distribution Data set are presented in an organized and easy to read format. Dataset that is large can also be visualized and this helps to see the trend of the data set.

Disadvantages include,

Loss of some information on individual data while adjusting datasetSome information can also be lost while organizing data using classes

Learn more on Symbolic Math Toolbox   here,

https://brainly.com/question/17856245

When obsolete routes can persist in the routing tables, packets can be misrouted or lost. This problem is known as the ________ problem.

Answers

Answer:

this is the count-to-infinity problem

Explanation:

The answer to this question is the count to infinity problem.

The Count to infinity problem is just a second name for what we call a routing loop. In distance vector routing, we have the occurrence of routing loops whenever an interface goes down. Its occurrence can also be due to two routers Which send updates to themselves simultaneously or at the same time.

When a program runs in a text-based environment, such as a command line interface, what determines the order in which things happen?

Answers

The set of commands will determines the order in which things

Check the devices that are external peripheral devices:

Mouse

Keyboard

Sound card

Internal modem

Answers

Answer:

mouse and keyboard

Explanation:

himothy

1. What is an advantage of the PCIe bus over the PCI bus?
2. Which type of devices typically use Mini PCI cards?
3. Which bus type is commonly used by graphics cards?
4. What type of slot can a PCIe x1 expansion card be placed in?

Answers

Answer:

Explanation:

1. PCI Express (PCIe) is a next generation I/O bus architecture. Rather than a shared bus, each PCIe slot links to a switch which prioritizes and routes data through a point-to-point dedicated connection and provides a serial full-duplex method of transmission.

2. Mini-ITX or Laptops

3.PCMCIA Personal Computer Memory Card International Association

4. PCIe x1 slot

You can run a macro by: Selecting the button assigned, Using the shortcut keys assigned, Using the view tab, Selecting run macro from the status bar​

Answers

Answer:

Run a macro by pressing a combination shortcut key In the Macro name box, click the macro that you want to assign to a combination shortcut key. Click Options. The Macro Options dialog box appears. In the Shortcut key box, type any lowercase or uppercase letter that you want to use with the shortcut key.

Explanation:

Answer:

the answer is D... Macros can carry viruses that can harm a computer.

Explanation:

YOUR WELCOME BABES!!!

irving is running cable underground beside his driveway to power a light at his entrance .what type of cable is he most likely using?
A.MC
B.NNC
C.UFD
D.UF

Answers

Based on the given information, Irving is running cable underground beside his driveway to power a light at his entrance. The most likely type of cable he would use in this scenario is "D. UF" cable.

Why is the cable Irving is using a UF cable and its importance

UF stands for "Underground Feeder" cable, which is specifically designed for underground installations.

It is commonly used for outdoor applications, such as running power to lights, pumps, or other outdoor fixtures. UF cable is moisture-resistant and has insulation suitable for direct burial without the need for additional conduit or piping.

Read more about cables here:

https://brainly.com/question/13151594

#SPJ1

A _______ is one typed character.
-gigabyte
-byte
-megabyte
-kilobyte
-terabyte

Answers

A bite byte bight beight

Transfer data across two different networks

Answers

this isn't a question. that is a STATMENT. please, ask a question instead of stating things on this site.

For everyday files that users will use regularly on a user's own Word-compatible computer, the best file format to save as is: o PDF. DOCX ORTE. OTXT.​

Answers

Answer:

DOCX? I think

Explanation:

You need to migrate an on-premises SQL Server database to Azure. The solution must include support for SQL Server Agent.

Which Azure SQL architecture should you recommend?

Select only one answer.

Azure SQL Database with the General Purpose service tier

Azure SQL Database with the Business Critical service tier

Azure SQL Managed Instance with the General Purpose service tier

Azure SQL Database with the Hyperscale service tier

Answers

The recommended architecture would be the Azure SQL Managed Instance with the General Purpose service tier.

Why this?

Azure SQL Managed Instance is a fully managed SQL Server instance hosted in Azure that provides the compatibility and agility of an instance with the full control and management options of a traditional SQL Server on-premises deployment.

Azure SQL Managed Instance supports SQL Server Agent, which is important for scheduling and automating administrative tasks and maintenance operations.

This would be the best option for the needed migration of dB.

Read more about SQL server here:

https://brainly.com/question/5385952

#SPJ1

In cell E4, enter a formula using relative cell references that multiply cell C4 by cell D4

In cell E4, enter a formula using relative cell references that multiply cell C4 by cell D4

Answers

Enter this formula into cell E4 (even the equals is needed)

=PRODUCT(C4:D4)

Programming languages such as Prolog support the (1)__________ programming paradigm because they encourage programmers to describe a(n) (2)___________ rather than its solution.

Answers

Programming languages such as Prolog support the (1) declarative programming paradigm because they encourage programmers to describe a(n) (2) problem rather than its solution.

In declarative programming, the programmer specifies what the program should accomplish rather than how it should be done. Prolog is a logic programming language that is particularly well-suited for tasks such as natural language processing, expert systems, and rule-based systems. In Prolog, the programmer defines a set of rules and facts, and the system uses logic to infer conclusions based on those rules and facts. This approach allows for more flexible and scalable programming, as the system can adapt to new data and rules without requiring significant changes to the code.

To know more about Prolog support click here:

brainly.com/question/29751038

#SPJ4

states that processing power for computers would double every two years

Answers

Answer:

Moore's Law

Explanation:

Python (and most programming languages) start counting with 0.
True
False

Answers

True....................

Answer:

yes its true  :)

Explanation:


Match List
Match the function to its purpose.
square root
an approximation of 7
greatest common divisor of two integers
:: sqrt()
#pi
::gcd(0)

Answers

square root:: sqrt()

an approximation of 7#pi

greatest common divisor of two integers::gcd(0)

Describe
the
Visual basic
select case construct​

Answers

Answer:

Select Case statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each select case.

Answer:

ggggggggggggggggggg

Three friends decide to rent an apartment and split the cost evenly. They each paid $640 towards the total move in cost of first and last month's rent and a security deposit. If rent is $650 per month, how much was the security deposit?
a.
$10
b.
$207
c.
$620
d.
$1,270



Please select the best answer from the choices provided

Answers

Answer:

c. $620

Explanation:

To find the cost of the security deposit, we need to subtract the amount paid towards the first and last month's rent from the total move-in cost.

Each friend paid $640 towards the total move-in cost, which includes the first and last month's rent and the security deposit. Since they split the cost evenly, the total move-in cost is 3 times $640, which is $1920.

The monthly rent is $650 per month, so the first and last month's rent combined is 2 times $650, which is $1300.

To find the security deposit, we subtract the first and last month's rent from the total move-in cost:

Security deposit = Total move-in cost - First and last month's rent

Security deposit = $1920 - $1300

Security deposit = $620

Therefore, the security deposit was $620.

Option c. $620 is the correct answer.

I need help with this its due today ahhhhhhh

I need help with this its due today ahhhhhhh

Answers

3rd and 4th sentence

1st question just take a hint

Rear the following passage about tripods. Choose the incorrect statement.
A tripod can make a huge difference in the sharpness and quality of the image and enable the photographer to use specialty techniques.
The main function of a tripod is to keep the camera steady in a precise position
A tripod prevents the picture from becoming blurred during low light or low shutter speed conditions. It also increases the depth of field for
sharper images
It is not important to consider the number of legs segments and the weight of the tripod while purchasing one.

Answers

Answer:

The answer is "It is not important to consider the number of legs segments and the weight of the tripod while purchasing one."

Explanation:

Because I just got it right

What can a programmer expect when writing a modular program for a game

Answers

Answer:

That it's gonna be hard.

Your game design company has recently asked all employees to use a specific personal information management application (PIM) to increase workplace efficiency. The PIM is collaborative, so contacts, calendar entries, and notes are shared across the team. Several team members are resistant to the idea, saying it interrupts their workflow, and they prefer their own way of handing contacts, notes, etc. Others don’t want their own notes to be seen by their coworkers.

Answers

Answer:For example, an office worker might manage physical documents in a filing cabinet by placing them in folders organized alphabetically by project name, or might manage digital documents in folders in a hierarchical file system.

Explanation:

Most shop accidents are caused by?

Answers

Answer:Most shop accidents are caused by÷

liftingpoor light trips and fallsstressdangerous materialsact of shop violencedehydrationextreme tiredness

Match the different aspects of the marketing information systems to the scenarios that portray them.
1. Marketing intelligence system
2. Internal reporting system
3. Marketing model
4. Marketing research system

A. includes number of orders received, stock holdings, and sales invoices
B. MIS collects, regulates, and analyzes data for marketing plan
C. gathers information such as demographic data
D. includes time series, sales model, and linear programming

Answers

Answer:

1. Marketing intelligence system - C

2. Internal reporting system - A

3. Marketing model - D

4. Marketing research system - B

Explanation:

Discuss your favorite video games and why you like them. What types of features make a game fun to play? Why are they features effective?

Answers

Answer:

My favorite video games are Rainbow Six Seige and For Honor

Explanation:

I like RSS because it keeps me etertained for a long time compared to other games where I get bored of them quickly and also because when you play with friends it's even more fun. I enjoy For Honor because it's like an olden days kinda game which for some reason is fun. : ) The features in both games are very realistic and that's what I like about them because when you have your headset on and you really in the zone it can sometimes feel like your in the game

Answer:

I like all of the games no favorite

Explanation:

What's the output of the following code?
var x = 10;
x = x + 4;
Console.log (“The value of x is "+x+"!");

O 14!
O The value of x is x!
O The value of x is 14
O The value of x is 14!

Answers

The answer should be "The value of x is 14!"

A detailed description is shown in the photo below. I wish you success!

What's the output of the following code? var x = 10; x = x + 4;Console.log (The value of x is "+x+"!");O

Router R1 lists a route in its routing table. Which of the following answers list a fact from a router uses when matching the packet's destination address? (choose 2)
A) Mask
B) Next-hop router
C) Subnet ID
D) Outgoing interface

Answers

The following options that are a fact from a router uses when matching the packet's destination address is A) Mask and C) Subnet ID. These two types address useful when forwarding packets that happen to match the route.

In the term of computer and technology, Routing generally can be defined as the process of selecting a path for traffic in a network or between or across multiple networks. In general, routing usually used   in many types of networks, such as  circuit-switched networks, such as the public switched telephone network, and computer networks, and others. Route can be classified into several types, such as connected route, local route, static route, and dynamic route.

Here you can learn more about routing https://brainly.com/question/30409461

#SPJ4

Write a program that asks the user to enter the size of a triangle (an integer from 1 to 50). Display the triangle by writing lines of asterisks. The first line will have one asterisk, the next two, and so on, with each line having one more asterisk than the previous line, up to the number entered by the user. On the next line write one fewer asterisk and continue by decreasing the number of asterisks by 1 for each successive line until only one asterisk is displayed. (Hint: Use nested for loops; the outside loop controls the number of lines to write, and the inside loop controls the number of asterisks to display on a line.) For example, if the user enters 3, the output would be:_______.a. *b. **c. ***d. **e. *

Answers

Answer:

Implemented using Python

n = int(input("Sides: "))

if(n>=1 and n <=50):

    for i in range(1,n+1):

         for j in range(1,i+1):

              print('*',end='')

         print("")

       

    for i in range(n,0,-1):

         for j in range(i,1,-1):

              print('*',end='')

         print("")

else:

         print("Range must be within 1 and 50")

Explanation:

This line prompts user for number of sides

n = int(input("Sides: "))

The line validates user input for 1 to 50

if(n>=1 and n <=50):

The following iteration uses nested loop to print * in ascending order

   for i in range(1,n+1):

         for j in range(1,i+1):

              print('*',end='')

         print("")

The following iteration uses nested loop to print * in descending order        

    for i in range(n,0,-1):

         for j in range(i,1,-1):

              print('*',end='')

         print("")

The following is executed if user input is outside 1 and 50

else:

         print("Range must be within 1 and 50")

Other Questions
there are a number of factors that alter the bioavailability of minerals from foods. complete each sentence with either increases or decreases. Multiply (3x 5y)(2x + 3y) How can an application use Amazon ElastiCache to improve database read performance? a. Read data from the database first and write the most frequently read data to ElastiCache. b. Direct all read requests to the database and configure it to read from ElastiCache when a cache miss occurs. c. Read data from ElastiCache first and write to ElastiCache when a cache miss occurs. d. Write data to ElastiCache whenever the application writes to the database. e. Replicate the database in ElastiCache, and direct all reads to ElastiCache and all writes to the database. If inspectors from the Food and Drug Administration arrive unannounced to inspect your manufacturing plant and criminal charges result from that inspection, you may be able to challenge those charges as a violation of the: _______. Edgar recently started a diet and meal plan to try to increase his muscle mass for the upcoming wrestling season. The plan requires Edgar to eat all meals during an 8-hour period,while fasting the rest of the day. He is not permitted to eat fruit or carbohydrates, but can eat as much meat, dairy, and vegetables as he wants during the 8-hours. Which statement bestsummarizes the potential health-risks of this diet?His caloric intake could be dangerously lowO This diet provides ample opportunities and food choices to obtain the required essential nutrientsHis blood sugar levels could be dangerously highHis total fat content could exceed the recommended daily allowance (Grammar0.5 Change the following sentences into future perfect tensea) Children like to play.b) Radha is reading a bookc) He behaved in a manner.d) Sonika runs a hotele) I am workingThe Sun rises in the east.Q.6 Make these verbs in present participle-a) finishb) informc) FeelQ.7 Change into negative sentencesa) Ram taught his students.b) We won the match What two elements should the first two headings in the header of the web page be enclosed in? group of answer choices h2 and h3 elements p and ul elements h1 and p elements h1 and h4 elements During Alexander the Greats reign, Darius III was the king of ? When tying cost to staffing for the annualizing method, the cost of nonproductive days is already in the formula. True or false the nile river delta is a flat area with fertile soil located inA. Lower Egypt B. Middle EgyptC. Upper Egypt please help i cant figure out which answer it is. An undisturbed chuck of soil has a wet weight of 62 lb and a volume of 0.56 ft3 . When dried out in an oven, the soil weighs 50 lb. If the specific gravity of solids is found to be 2.64, determine the water content, wet unit weight of soil, dry unit weight of soil, void ratio, porosity, and the degree of saturation. identify some ways racism impacts society Which of the following contributes to the author's development of an informal tone of Selection 1instead of the formal tone of Selection 2?Athe exclusive use of first person point-of-viewBthe exclusive use of second person point-of-viewthe use of both first and second person point-of-viewDthe use of both second and third person point-of-view An electronics manufacturer has 34 days-of-supply of inventory for a particular cell phone model. (Round your answer to 1 decimal place.) Assuming 365 days per year, what is the annual inventory turns of this cell phone model? Please don't answer if you don't know, please!!It's about integrals. I know the answer but I'm not sure of the working. Identify the key differences between the Articles of Confederation and the U.S. Constitution. Then explain which document created the better system of government for the new nation, and support your response with the differences you have identified. Medical Savings Accounts (MSAs) are available to small business employees and self-employed individuals who have giving the same or similar speech for multiple audiences is one of the best ways to build confidence and reduce speech anxiety. I cant find them?Adverbs