subject

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. */
}
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 23:50
You need to design a circuit that implements the functions in the following table: s0 s1 function0 0 a + 10 1 a – b1 0 a + b1 1 a – 1s0 and s1 are 1-bit control inputs to select the function of the circuit. inputs a and b are 4-bitnumbers in 2s complement form. the output is also a 4-bit number in 2s complement form.you are allowed to use only one ttl 7483 4-bit adder to implement all the functions. but anynumber of other components (except the adder) can be used.hint: design a combinational logic circuit to modify the input b and the “carry input” of theadder depending on the control inputs s0 and s1.important: lab grade will depend on the working of the circuit & will be checked of by your labinstructor.1. is the output valid for the following input combinations: a. s0 = 0, s1 = 0, a = 7, b = 3? b. s0 = 0, s1 = 1, a = 7, b = 3? c. s0 = 1, s1 = 0, a = -4, b = -5? d. s0 = 1, s1 = 1, a = -8, b = 6? 2. what is the range of inputs (for both a and b) that will produce the valid output for all the functions?
Answers: 3
question
Computers and Technology, 23.06.2019 14:30
Select the correct answer. a company wants to use online methods to target more customers. it decides to conduct a market research by collecting the data of a few customers with their consent. they want to track data of the sites that their customers frequently visit. which software can the company? a. spyware b. bots c. adware d. trojan horse e. rootkits
Answers: 1
question
Computers and Technology, 24.06.2019 11:20
Every telecommunication setup uses two devices: one device to transmit data and one device to receive data. which device transmits frequencies to mobile phones? towers transmit frequencies to mobile phones.
Answers: 1
question
Computers and Technology, 24.06.2019 20:30
How is energy expended in active transport
Answers: 1
You know the right answer?
Write in Java: Given a long integer representing a 10-digit phone number, output the area code, pre...
Questions
question
History, 16.04.2021 23:10
question
History, 16.04.2021 23:10
question
History, 16.04.2021 23:10
question
Mathematics, 16.04.2021 23:10
Questions on the website: 13722362