
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
IN JAVA Write a function that takes in user input as a string. For all characters which are numeric, double its value and, if it is two digits, then replace it with the sum of its digits (e.g., 6 → 12 → 3 whereas 3 → 6). For all characters which are in uppercase, replace it with lowercase. For all characters which are in lowercase, replace it with uppercase (e.g., m → M and N → n). The
![**Example Explanation:**
- If the input is "3rD", then the output is "6Rd".
- If the input is "6sT", then the output is "3sT".
- The first number (6) becomes 3 because 6 times 2 is 12 and the sum of its digits is 3 (1+2).
**Console Output Transcription:**
```
Please enter [q] or [Q] to terminate the program!
Original string (input) : 3rD
Converted string (output): 6Rd
Original string (input) : 6sT
Converted string (output): 3sT
Original string (input) : Q
Terminating upon user's request!
```
This example demonstrates a simple program that modifies input strings based on specific rules. The transformation involves altering numbers by doubling them and summing the digits of the product to get a single-digit result. The program continues to convert strings until terminated by the user with input 'Q' or 'q'.](https://content.bartleby.com/qna-images/question/be73d2f7-f48d-4799-ad26-f906d4f73fa5/c7bcc88b-02e6-4f7e-acf8-ae51c2e07d49/qkipc6r_thumbnail.png)
Transcribed Image Text:**Example Explanation:**
- If the input is "3rD", then the output is "6Rd".
- If the input is "6sT", then the output is "3sT".
- The first number (6) becomes 3 because 6 times 2 is 12 and the sum of its digits is 3 (1+2).
**Console Output Transcription:**
```
Please enter [q] or [Q] to terminate the program!
Original string (input) : 3rD
Converted string (output): 6Rd
Original string (input) : 6sT
Converted string (output): 3sT
Original string (input) : Q
Terminating upon user's request!
```
This example demonstrates a simple program that modifies input strings based on specific rules. The transformation involves altering numbers by doubling them and summing the digits of the product to get a single-digit result. The program continues to convert strings until terminated by the user with input 'Q' or 'q'.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 4 steps with 2 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- 1. Implement function postal() that takes 6 inputs: a first name (as a string) a last name (as a string) an address (as a string) a city (as a string) a state (as a string) a zip code (as an integer)and then prints a mailing address in 3 lines as shown below.>>> postal('Ljubomir', 'Perkovic', '243 S Wabash Ave','Chicago', 'IL', 60304)Ljubomir Perkovic243 S Wabash AveChicago, IL 60304arrow_forwardWrite a function biggestBuried(s), which the parameter s is a string, and the function returns the largest integer buried in the string. If there is no integer inside the string, then return 0. For example, biggestBuried('abcd51kkk3kk19ghi') would return 51, and biggestBuried('kkk32abce@@-33bb14zzz') would return 33, since the '-' character is treated like any other non digit. Note that a character is a digit if it is greater than or equal to '0' and less than or equal to '9'. Alternatively, you can use string.isdigit() to check if the string is a digit. Use the function in a program to test that it works properly by saying print(biggestBuried('abcd51kkk3kk19ghi')) answer should be 51 print(biggestBuried('kkk32abce@@-33bb14zzz')) answer should be 33 print(biggestBuried('this15isast22ring-55')) answer should be 55arrow_forwardWrite a python function called replacer() that takes two strings as arguments. Argument1: A sentence where you have to make the changes. Argument2: A word with the values either “vowel” or “consonant”.Your function should replace the characters of the sentence with “V” or “C” depending on the 2nd argument. If the word is “vowel”, then replace all the vowels with “V”. If the word is “consonant”, then replace all the consonants with “C”.[You are not allowed to use the replace() function]Function call1:replacer("It is MAT110 final", "vowels")Sample Output1:Vt Vs MVT110 fVnVlFunction call2:replacer("It is CSE110 final", "consonants")Sample Output 02:IC iC CCE110 CiCaCarrow_forward
- Write a C++ program that reads a sentence into a c-string of maximum 80 characters, a character into a variable called c, and an integer into n, and then passes all three of these variables to a function that searches for the character c and prints the character and the next n characters of the string, if the character is found. If it doesn't find the character in the string it must print "The character was not found." For example, if the user enters "Superbowl tickets are too expensive." and then enters t and 7, the function must print tickets.arrow_forwardImplement a function eligible in Python that returns a list of the names of people that are eligible for vaccination, subject to a minimum age requirement. The function eligible must: accept two arguments: 1. the minimum age for eligibility, a positive integer 2. a multiline string, containing the people waiting to be vaccinated. Each line of the stringcontains a person's name and their age, separated by a single space. return a list of the people who are eligible to be vaccinated, i.e., those whose ages is at least that of the minimum age for eligibility. They should be listed in the order they occur in the input string. Sample: >>> people = 'Sue 25\nAli 45\nSyd 45\nSally 105\nIan 16\nUli 65\nOliver 23\nZoe 95'>>> print(people)Sue 25Ali 45Syd 45Sally 105Ian 16Uli 65Oliver 23Zoe 95arrow_forwardImplement a function alterCase in Python that converts a word to "alterCase". Given a word, using any mix of upper and lower case letters, the function then returns the same word, except that the first letter is upper case, the second is lower case, and then cases of letters alternate throughout the rest of the word. >>> alterCase('apple')'ApPlE'arrow_forward
- code should be python: write a function that allows the input of a list of strings as its only parameter. Inside the body of the function find the first palindromic word and return it. If there is no such word, it should return an empty string. A string is palindromic if it reads the same forward and backward so for example If we call the function with [“horse”, “rat”, “roar”, “dad”, “mom”], the returned value should be “dad”. Note that “mom” is also a palindrome, but it is not the first one.arrow_forwardWrite a function in Scala programming language that takes a string parameter and returns whether the string starts with "Sc" or not. Test the function for the sample strings "Scala", "Programming", "Science".arrow_forwardPHP Write a wordFilter function Write a function wordFilter($str) that takes a string representing a sentence as a parameter. It should replace all occurrences of certain blacklisted words with asterisks of the same length and return the substituted sentence. The words “shoot” “darn” and “fudge” (case insensitive) are considered blacklisted. However, these words as part of a larger word should be left alone (e.g. overshoot is fine as it is). Use one or more regular expressions with replacements in your solutions (e.g. preg_replace).arrow_forward
- Write a program that inputs a student's name in the following form: lastName, firstName middleName. The program will convert the name to the following form: firstName middleName lastName. Your program must read the student's entire name in one variable and must consist of a user-defined function that takes as input a string, consisting of a student's name, and returns the string consisting of the altered name. You can use the string function find to find the index of ,(the comma); the function length to find the length of the string; and the function substr to extract the firstName, middleName, and lastName.arrow_forwardWrite a program to enter two strings from the user using function cin.getline and then appends string two with string one separated by a blank space. Sample Input: C++ is a good programming Language. Arrays are very integral part of this language. Sample Output: C++ is a good programming Language. Arrays are very integral part of this language.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- 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

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education