
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
Implement the following two methods in javascript:
String multiply2(String num) - return num*2 without changing num to numeric value. You will have to scan num using a for loop. In the loop you will pull out each digit, double it, and build into another string considering carry bits.
For num = “82739112345678”, return “165478224691356”.
String divide2(String num) - return num/2(integer division) without changing num to numeric value. You will have to scan num using a for loop. In the loop you will pull out one or two digits, halve it, and build into another string considering borrow bits.
For num = “165478224691357”, return “82739112345678”.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 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
- This method returns a string with a rectangle that has maxRows and maxCols, using the symbol character. The method will return a special value null if maxRows and maxCols are less than 1. The method most not rely on System.out.println(). No Arraysarrow_forwardJava Method called reverse that reverses a string passed to this method as a parameter and returns the reversed string. You should use for loop. You should not use external methods. E.g. reverse("string") should return gnirts. class Main {public static void main(String[] args) {}}arrow_forwardAdd a while loop to the BMI prcoedure below. def BMIImperial(height, weight, bmiList, Category): BMI = (weight * 703) / (height * height)print ("Your BMI is " + str(BMI))if (BMI <= bmiList[0]):print(BMI)print('you are:', Category[0])elif (BMI <= bmiList[1]):print('you are:', Category[1])elif (BMI <= bmiList[2]):print('you are:', Category[2])else:print('you are:', Category[3])arrow_forward
- An array of binary strings is given and you have to find the decimal number of each entry and store in new array and print the new array In JavaScriptarrow_forwardCan your understanding of computer operating systems be enhanced by studying assembly language?arrow_forwardPrint the two strings, firstString and secondString, in alphabetical order. Assume the strings are lowercase. End with newline. Sample output: capes rabbits 365076.2342078.qx3zay7 1 import java.util.Scanner; 3 public class OrderStrings { public static void main (String 0 args) { Scanner scnr = new Scanner(System.in); String firstString; String secondString; 4 5 7 8 firstString secondString = scnr.next(); 9 scnr.next(); 10 11 12 * Your solution goes here 13 } 15 } 14arrow_forward
- Given a long string use recursion to traverse the string and replace every vowel (A,E,I,O,U) with an @ sign. You cannot change the method header. public String encodeVowels(String s){ // Your code here }arrow_forwardWrite a program that converts date formats from American Format: “February 4, 2021” to International Format, such as “2021-February-4”. Hint: you may use several string methods, including: str.indexOf(c) and str.substring(p, q). Note: java programming, must detect commaarrow_forwardclass Output{public static void main(String args[]){byte a[] = { 65, 66, 67, 68, 69, 70 };byte b[] = { 71, 72, 73, 74, 75, 76 };System.arraycopy(a , 0, b, 0, a.length);System.out.print(new String(a) + " " + new String(b));}} The output of the above Java code is ?arrow_forward
- e) Create a new StringBuilder from the String "Prepare for your Midterm Exam". Check the capacity of the StringBuilder and if it's empty. Find the index of the letter 'y'. Delete a substring from the starting index till this index (of 'y'). Insert a string "Good luck on " at the beginning of the StringBuilder. Append '!" to it. Print your StringBuilder to Console.arrow_forwardIn java Language Write the method named shift3()* * You are given a String str. Return a new String where* all of the characters are "shifted" by 3. Here is the* algorithm to do this* 1. Visit each character in the String* 2. Create a new char by adding 3* 3. Store the new character in the output string** Examples:* shift3("hello") returns "khoor"* shift3("cat") returns "fdw"* shift3("frog") returns "iurj"** @param str the String to start with* @return the rotated String as described herearrow_forwardRevorse the vewels def reverse_vowels(text): Given a text string, create and return a new string constructed by finding all its vowels (for simplicity, in this problem vowels are the letters found in the string 'aeiouAEIOU') and reversing their order, while keeping all other characters exactly as they were in their original positions. However, to make the result look prettier, the capitalization of each moved vowel must be the same as that of the vowel that was originally in the target position. For example, reversing the vowels of 'Ilkka' should produce 'Alkki' instead of 'alkkI'. Applying this operation to random English sentences seems to occasionally give them a curious pseudo-Mediterranean vibe.Along with many possible other ways to perform this square dance, one straightforward way to reverse the vowels starts with collecting all vowels of text into a separate list, and initializing the result to an empty string. After that, iterate through all positions of the original text.…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
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