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
Given a string variable s that has already been declared, write some code that repeatedly reads a value from standard input into
valina [46]

Answer:

The code to this question can be given as:

Code:

while ((s!="Y" && s!="y" && s!="N" && s!="n"))  //loop for check condition

{

cin >> s;  //insert value

}

Explanation:

The description of the following code:

  • In this code, we use a string variable s that has been to define in question.
  • In code, we use a while loop. It is an entry control loop in loop we check variable s value is not equal to "y", "Y", "n" and "N".  
  • In the loop we use AND operator that checks all value together. If this is true So, we insert value-form user input in string variable that is "s".
4 0
3 years ago
what are the advantages of breaking up a single logical message into a number of fixed-sized packets and then sending each one o
aleksklad [387]

Explanation:

These are the advantages of breaking up a single logical message into a number of fixed sized packets.

- When messages are broken into packets it increases the performance and also the reliability of the internet

- if there is an error in a single packet, this error is not going to affect the entire message.

- the efficiency of the communication line in the internet is improved.

- there is a reduction of traffic. Each packet in a single message can be transmitted through different routes.

- It reduces idleness as each packet can send from different program so each program has a service.

8 0
3 years ago
Match the correct pairs of column A and B to prove your computer
ohaa [14]

Explanation:

1 Ms word - b. Word processing software

2 Pagemaker - c desktop publishing

3 Ms excel - f finance and data analyses

4 dbase - a database management system

6 Mcafee/Norton - d anti-virus software

7 virus - h computer program that can replicate itself

8 inbox, compose,.............. - parts of an email account

5 0
3 years ago
Tab stops are useful when you want to?
Lelu [443]
Indentation and alignment are very noticeable on a printed page, so you will probably want to set the tab stops in your document precisely how you want them.


8 0
3 years ago
The rangevalidator object on a web form has a type property for identifying the type of data for the range, such as ____.​
mojhsa [17]
<span>numbers,  dates, currency or strings - The range validator in a web form helps check whether the value entered in the field falls between the minimum and maximum values allowed in that field. For example if the type of data accepted  is of date type, then the rangevalidator checks whether the entered date falls within the given range. That means, month entered should be between 1 and 12, etc.</span>
8 0
3 years ago
Other questions:
  • Assume that printStars is a function that takes one argument and returns no value. It prints a line of N stars (followed by a ne
    13·1 answer
  • Create a class ProblemSolution with following characteristics Two private member variables name &amp; designation of string type
    8·1 answer
  • GUI stands for "___ user interface."
    9·2 answers
  • The while loop is a pre-test loop? TRUE OR FALSE
    9·2 answers
  • Implement a program to measure the impact of application-level buffer sizes on read time. This involves writing to and reading f
    13·1 answer
  • What has information technology made piracy possible?
    14·1 answer
  • How did you generate a random number for the user to guess?
    9·1 answer
  • A ______ is a portable device for recording audio and video.
    10·2 answers
  • How can she change that value so it is reflected in the chart in her presentation?
    5·2 answers
  • Identify the three fuzzy logic systems in the given text.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!