1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
RoseWind [281]
3 years ago
11

LAB: Convert to binary - methods

Computers and Technology
1 answer:
Georgia [21]3 years ago
8 0

Answer:

import java.util.Scanner;

public class Lab{

  public static String integerToReverseBinary(int number)

  {

      String binary = "";

      if(number == 0){

          return "0";

      }

      while(number > 0)

      {

          int remainder = number % 2;

          number = number / 2;

          binary += Integer.toString(remainder);

      }

      return binary;

  }

 

  public static String reverseString(String wordString)

  {

      String binaryString = "";

      int length = wordString.length();

      for(int i = length -1 ; i >= 0 ; i--)

      {

          binaryString += wordString.charAt(i);

      }

      return binaryString;

  }

 

Explanation:

In the java source code, the Lab class is defined which has two methods, 'reverseString' and 'integerToReverseBinary'. The latter gets the argument from the former and reverses the content of its string value, then returns the new string value. The former gets the integer value and converts it to its binary equivalence for which are converted to strings and returned.

You might be interested in
This diagram shows some peripheral devices for a computer: which of the following is true
CaHeK987 [17]

Where is the diagram and answers?

4 0
3 years ago
A file is to be shared among different processes, each of which has a unique number. The file can be accessed simultaneously by
UkoKoshka [18]

Answer:

monitor fileSharer

{

       enum {THINKING, WAITING, READING} state[N];

       condition self[N];

       int total;

       void open(int i) {

               state[i] = WAITING;

               if (i + total >= N)

               { self[i].wait(); }  // Leaves monitor

               state[i] = READING;

               total += i;

       }

       void close(int i) {

               state[i] = THINKING;

               total -= i;

               // Can signal one waiting proc whose ID won't break bank.

               for (int x = N - total - 1; x >= 0; x--) {

                       if (state[x] == WAITING) {

                               self[x].signal(); break;

                       }

               }

       }

       initialization.code() {

               for (int i = 0; i < N; i++) {

                       state[i] = THINKING;

               }

               total = 0;

       }

}

8 0
4 years ago
Which of the following statements is true about mobile devices and procedures?
Zarrin [17]

Answer:

No

Explanation:

No

5 0
3 years ago
What should you do with a wireless-capable laptop if you connect a lan cable to it?
marusya05 [52]
A local-area network (LAN<span>)  cable is used in LAN networks to connect several computers or other networking devices.</span>
If you connect a LAN cable to a wireless-capable laptop you should turn the wireless capability off to maximize security, because through the LAN cable viruses can be transmitted, than can harm your computer.

6 0
3 years ago
Read 2 more answers
Define a character variable letterStart. Read the character from the user, print that letter and the next letter in the alphabet
lesantik [10]

Answer:

  1. declare variable
  2. get input
  3. display variable and also increment ASCII of variable and th en display it

Explanation:

  • In above code first we declare a character variable by (var).
  • Then we get a character input from user in (var).
  • Then display character input and at the same time we also display next character by incrementing the ASCII of character input by 1.
3 0
4 years ago
Other questions:
  • . Write a statement that throws an IllgalArgumentException with the error message Argument cannot be negative.
    11·1 answer
  • Now imagine that we have a list of 5 employees who have each worked 45, 15, 63, 23, and 39 hours. We'll fix rate_of_pay at 10. P
    10·1 answer
  • What is the output of the following function if the array nums contains the values 1 2 3 4 5 int backwards(int nums[]) { for (x
    15·1 answer
  • Write an expression that whose value is the fifth character of the string name.
    10·1 answer
  • In what way is your social media footprint related to your digital ID
    12·1 answer
  • What has been your background with using Windows-based computers?
    6·2 answers
  • 5. The operating system has two components
    12·2 answers
  • JAVA
    12·1 answer
  • Which letter shows the ball when it has the maximum kinetic energy
    15·1 answer
  • In Python, which comparison operator means "less than or equal to"?
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!