Concept explainers
Write a
Please enter an integer between 1,000 and 999,999: 23,456
23456
Hint: Read the input as a string. Measure the length of the string. Suppose it contains n characters. Then extract substrings consisting of the first n – 4 characters and the last three characters.
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
BIG JAVA: LATE OBJECTS
Additional Engineering Textbook Solutions
Starting Out with Programming Logic and Design (4th Edition)
Problem Solving with C++ (9th Edition)
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Starting Out with Python (4th Edition)
Modern Database Management (12th Edition)
- Write a program that reads a string and checks the longest substring starting with "a" and ending with "z" included in it. Note that, the substring cannot contain another a or another z in it. For example: Ifs="bcd bbccdd badefgze tabdz", the longest substring is: 6arrow_forward1. a Write a regular expression for the set of binary strings where each string has at least one pair of consecutive zeros. b. write the regular expression for the following, where sigma = (a,b): i. string of length at least 2 ii. string of length at most 2 iii. all string starting with a and ending with b iv. Even length Stringsarrow_forward2. Generate a random string of length 10 that contains only lowercase alphabets from 'a' to 'z'. Print the string in the output.arrow_forward
- 6. A palindrome is a number or text phrase that reads the same backwards or forwards. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554 and 11611. Write a program that reads a 5 digit integer and determines whether it is a palindrome. Hint: One way to do this is to use division (/) and modulus (%) operators to separate the number into individual digits.arrow_forwardWrite a program which reads string and rewrite it in alphabetical order. For example, the word STRING should be written as GINRST.arrow_forwardWrite a program that gets a string from the user and reports whether or not there are repeated characters in it based on the following program. loop ask the user to input one of the characters a, b, c, d, e, q read in a character from the keyboard if the character is'a' output your name and your tutor's name (hard-coded)'b' input 3 double numbers x, y, z and output the largestand the smallest of the three numbers'c' input 2 integer numbers m and n, and display all thenumbers between m and n (both inclusive) with fivenumbers per line (note that the last line may have lessthan 5 numbers). At the end, display the sum of all theodd numbers between m and n (both inclusive)'d' input 3 integer numbers representing the sides of atriangle and display the numbers together with amessage indicating whether or not the numbers form atriangle (Note: for the numbers to form a triangle, thesum of any two sides must be greater than the thirdside)'e' input an integer number n and determine whether or…arrow_forward
- Write a program that reads the full name of a student; and then prints it in the form: last first middle initial. Example: Input: Ali Hamad Al-Harbi Output: Al-Harbi, Ali H. Write a program that reads a string composed of three words separated by a space, and then print each word on a separate line. Input: one two three Output: One two threearrow_forwardWrite a program that reads from the user a character ('q' or 'c'). If the character is 'c', the program reads from the user the radius rof a circle and prints its area. • If the user enters 'q', the program asks the user to enter the length and width of a quadrilateral. We assume the quadrilateral is either a square or rectangle. You should print if the quadrilateral is square or rectangle. • Otherwise, it prints "Wrong character" PS: Use the following formulas: area of circle=3.14*r Sample Run1: Enter a character (q or c): q Enter the Length and Width: 80 150 |It is a rectangle Sample Run2: Enter a character (q or c): q Enter the Length and Width: 80 80 It is a square Sample Run3: Enter a character (q or c): c Enter the radius: 2 The area of the circle is 12.56 Sample Run4: Enter a character (q or c): d Wrong characterarrow_forwardPlease &-. Write a Java program to check if a given string is a palindrome or not. A palindrome is a word, phrase, number, or other sequence of characters that reads the same backward as forward, ignoring spaces, punctuation, and capitalization. For example, "racecar" and "Madam" are palindromes, while "hello" and "Java" are not. Your program should take a string as input and return true if it's a palindrome, and false otherwise. Ik.?arrow_forward
- Q12,. A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers. Given a string s, return true if it is a palindrome, or false otherwise. Example 1: Input: s = "A man, a plan, a canal: Panama" Output: true Explanation: "amanaplanacanalpanama" is a palindrome. Example 2: Input: s = "race a car" Output: false Explanation: "raceacar" is not a palindrome..arrow_forwardWrite a program that asks the user to enter a string, and then converts that string to Morse code. Use hyphens for dashes and periods for dots. Morse Code Table Character Code Character Code Character Code Character Code space space 6 - . . . . G --. Q --.- comma --..-- 7 -- . . . H . . . . R .-. period .-.-.- 8 ---.. I .. S . . . question mark ..--.. 9 ----. J .--- T - 0 ----- A .- K -.- U ..- 1 .---- B - . . . L .-.. V . . . - 2 ..--- C -.-. M -- W .-- 3 . . . -- D -.. N -. X -..- 4 . . . .- E . O --- Y -.-- 5 . . . .. F ..-. P .--. Z --..arrow_forwardWrite a Python program that compares two strings (character by character) and prints the number of similar characters. Example: Enter 1st string: This is a text Enter 2nd string: This is another text 9.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