Computers and Technology
Computers and Technology, 22.12.2020 03:10, mgreenamb

LAB: Convert to binary - methods Write a program that takes in a positive integer as input, and outputs a string of 1's and O's representing the integer in binary. For an integer X, the algorithm is:
As long as x is greater than 0
Output x 2 (remainder is either 0 or 1)
x = x/ 2
Note: The above algorithm outputs the O's and 1's in reverse order. You will need to write a second function to reverse the string
Ex: If the input is:
6
the output is:
110
Your program must define and call the following two methods. The method integerToReverseBinary should return a string of 1's and O's representing the integer in binary (in reverse). The method reverseString should return a string representing the input string in reverse.
public static String integerToReverseBinary(int integerValue)
public static String reverseString(String inputString)
Note: This is a lab from a previous chapter that now requires the use of a method.
ACTIVITY 6.32.1: LAB: Convert to binary-methods
LabProgram. java Load default template...
1 import java. util. Scanner;
2
3 public class convertToBinary 1
4
5 public static String integerToReverseBinary(int integervalue) {
6 String binary = "";
7 while (integervalue > 0) {
8 binary += String. valueof(integervalue % 2);
9 integervalue /= 2;
10
11 return binary;
12
13
14 public static String reverseString(String inputstring) {
15 String reversed = ""
16 for (char letter : inputstring. tocharArray() {
17 reversed = String. valueof(letter) + reversed;
18
19 return reversed;
6.34 LAB: Acronyms
An acronym of the input. If a word begins with a lower case letter, dont include that letter in the acronym. Assume there will be at least one upper case letter in the input.
Ex: If the input is:
Institute of Electrical and Electronics Engineers
the output should be:
IEEE
Your program must define and call a method thats returns the acronym created for the given userPhrase. public static String createAcronym(String userPhrase)
Hint: Refer to the ascii table to make sure a letter is upper case.
LAB ACTIVITY 6.34.1: LAB: Acronyms
LabProgram. java Load default template...
1 import java. util. Scanner;
2
3 public class Acronym {
4
5
6 public static String createAcronym(String userPhrase) {
7 string acronym = "";
8 for (String word: userPhrase. split("\\5+")) {
9
10 if (Character. i suppercase (word. charAt(e))) {
11 acronym += String. valueof(word. charAt(e)); NEOPHOBO
12
13
14
15 return acronym;
16
17
18
19 public static void main(String[] args) {
20
21 Scanner scanner = new Scanner(System. in);

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 24.06.2019 17:40, penacesar18p9jrdh
The value of sin(x) (in radians) can be approximated by the alternating infinite series create a function (prob3_2) that takes inputs of a scalar angle measure (in radians) and the number of approximation terms, n, and estimates sin(x). do not use the sin function in your solution. you may use the factorial function. though this can be done without a loop (more efficiently), your program must use (at least) one. you may find the mod() function useful in solving the problem.
Answers: 1
image
Computers and Technology, 24.06.2019 18:20, bm42400
The following if statement contains a logic error, not a syntax error. rewrite it so that it is correct. assume the variable age already exists and holds a valid number. if (age == 18 & & age == 19) {
Answers: 1
image
Computers and Technology, 25.06.2019 02:00, whocares1819
Lisa is making a presentation for her project and she wants to use the logo of her company in her presentation. which element would she use to make her logo stand out in her presentation? a. gradation b. contrast c. alignment d. balance
Answers: 1
image
Computers and Technology, 25.06.2019 06:00, tay8556
Write a method public static string getdigits(string phonenumber) that takes an 11-character phone number written with any combination of 11 uppercase letters, lowercase letters and/or digits, and zero or more hyphens, and which returns the digits that a person would have to press on a cell phone to dial that phone number. we will use the mapping of letters to digits given at en. wikipedia. org/wiki/telephone_keypad# /media/file: telephone-keypad2.svg you may assume that the string parameter phonenumber contains some combination of exactly 11 uppercase letters, lowercase letters and/or digits, but that any number of hyphens may be present. you can assume that a hyphen will not appear as the first or last character of the string. do not assum
Answers: 3
Do you know the correct answer?
LAB: Convert to binary - methods Write a program that takes in a positive integer as input, and out...

Questions in other subjects: