Write a short
The output should be:
N | Square Root |
1 | 1.000 |
2 | 1.414 |
3 | 1.732 |
4 | 2.000 |
5 | 2.236 |
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
Problem Solving with C++, Student Value Edition plus MyProgrammingLab with Pearson eText -- Access Card Package (9th Edition)
Additional Engineering Textbook Solutions
Database Concepts (8th Edition)
Starting Out with Java: Early Objects (6th Edition)
Digital Fundamentals (11th Edition)
Starting Out with Programming Logic and Design (4th Edition)
Absolute Java (6th Edition)
Starting Out with C++ from Control Structures to Objects (8th Edition)
- This is the question - Write a program that inserts parentheses, a space, and a dash into a string of 10 user-entered numbers to format it as a phone number. For example, 5153458912 becomes (515) 345-8912. If the user does not enter exactly 10 digits, display an error message. Continue to accept user input until the user enters 999. This is the code I have - However it isn't seeming to accept my output. It doesn't like what I have for some reason - import java.util.*; public class PhoneNumberFormat { public static void main(String[] args) { // Write your code here //Create an instance of Scanner class Scanner keyboard=new Scanner(System.in); //declare string data type variables String phoneNumber= ""; String formattedPhoneNumber=""; /*Run the loop infinitely until user enters 999 to exit from program*/ while(true) { System.out.println("Enter phone number: "); phoneNumber=keyboard.nextLine(); //exit…arrow_forwardFind out the final values of a,b and c where following expressions are executed sequentially:[4]int a = 2, b =3, c;a = (b++) + (++b) + a;c = a>b ? a:b;b = (a++) + (b--) + a;c = c++*b--;arrow_forwardWrite a program that displays the following table. Calculate the middle point of two points.arrow_forward
- I have done the code, but feel free to do it again. I am stuck on how to set the limits so the input stays between 0 and 50. Please use C not C++, thank you so very much. The question is: Write a program that prints a table using ASCII (printable) characters with each line giving an integer, its square root, its square, and its cube. Ask the user to enter a lower and upper limit for the table, but set limits so that input stays between O and 50. use for to do a loop.arrow_forwardWrite a program called KiloToPoundTable that prints the below table. Useprintf()and while statement. No credit if while statement is not used. Kilograms Pounds1 2.23 6.65 11.07 15.49 19.811 24.313 28.715 33.11) 1 kilogram is 2.20462 pounds (so, 2nd row will be 3 * 2.20462)2) Use while statement to iterate3) Set width to 12 for each column4) Use printf() for precision up to tenths placearrow_forwardWrite a program that displays a table of pounds and equivalent weights in kilograms. You can find the conversion factor online if necessary. Store this factor in a properly named constant. Allow the user to specify the range of pounds for the table by prompting for the start, stop, and step values for the pounds column. Display the pounds accurate to two decimal places centered in a column 10 characters wide. The kilometers should display accurate to three decimal places and right-aligned in a column 12 characters wide (see page 75-78). Column headings should be displayed with the same alignments. See Sample Output.arrow_forward
- What is the value of the postfix expressions below? A=1, B=2, C=3< d=4 a. AB+C b. ABC**ABC++-arrow_forward(This if for mindtap on cengage, if not possible, use devc++ 5.11 but mindtap is more accurate, mindtap is very tricky with wording so please make sure everything is word for word on the sample picture) Write a program that allows the user to enter the last names of five candidates in a local election and the number of votes received by each candidate. The program should then output each candidate’s name (Candidate), the number of votes received (Votes Received), and the percentage of the total votes received by the candidate (% of Total Votes). Your program should also output the winner of the election. Your program must contain at least the following functions: a function to determine the sum of votes. a function to output the winner of the election.arrow_forwardConsider the following code fragment, where the variable letter contains an uppercase letter: if 'A' <= letter <= 'U':...print("You entered a vowel")else:...print("The letter is not a vowel") Based on the ordering of characters in the ASCII table, which of the following statements is not true about this code? Select one: a. Prints You entered a vowel for all vowels b. Prints You entered a vowel for all vowels and all consonants. c. Prints You entered a vowel for some consonants. d. Prints The letter is not a vowel for some consonants.arrow_forward
- What is the value of the following expression: 9 * 2 - 8 > 5 + 2 / 2? a. False b. 10 c. True d. 6arrow_forwardImplement the following: 1) Request a user input for the variable, direction.2) Write an if-elif-else statement to do the following: a) if the direction is 'N', print a message, North Zone. b) if the direction is 'S', print a message, South Zone. c) if the direction is 'E', print a message, East Zone. d) if the direction is 'W', print a message, West Zone. e) if the direction is none of the above, print a message, Invalid Input. f) uppercase and lowercase should be all acceptable. Example Output 1Enter your direction(N/S/E/W): uptownInvalid Input. Example Output 2Enter your direction(N/S/E/W): eEast Zone. NEED HELP WITH PYTHON CODEarrow_forwardAdd a print statement to say “Multiplication Table” and then prompt the user to enter an integer. Your program should then print a “times table” for the numbers from 1 to the given integer (inclusive). That is, for input n, you would print a table of n rows (lines) each with n columns, where the cell at row i and column j contains the value i × j. The coding language must be Java.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education