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
Karo-lina-s [1.5K]
3 years ago
7

Write a method named decimalToBinary that accepts an integer as a parameter and returns an integer whose digits look like that n

umber's representation in binary (base-2). For example, the call of decimalToBinary(43) should return 101011. Constraints: Do not use a string in your solution. Also do not use any built-in base conversion methods like Integer.toString .
Computers and Technology
1 answer:
zmey [24]3 years ago
7 0

Answer:

In Java:

public static int decimalToBinary(int decimal){

int binary = 0; // initial value

int currUnitPlace = 1; // working location

while(decimal > 0) {

// put remainder in current unit place

binary += currUnitPlace * (decimal%2);

decimal /= 2; // move to next bit

currUnitPlace *= 10; // move unit place

}

return binary;

}

You might be interested in
Which tool lets you increase the view, but not the size, of text, images, and other content?
blagie [28]
Use ctrl + or - or if in microsoft word, use the zoom tool
7 0
3 years ago
What is a reason to use a pseudo-class in Dreamweaver?
gulaghasi [49]

Answer: Option C is correct

Explanation:

Option C is correct

3 0
2 years ago
Consider the following pseudocode:
In-s [12.5K]

Answer:

Part a:  The program will print 3.

Part b: The program will print 4

Part c: The program will print 1.

Explanation:

Part a: As the scoping is static, the x integer has a value of 1 and the y integer has a value of 2 so the addition is 2+1=3.

Part b: As the scoping is dynamic with deep binding, the x integer has a value of 2 and the y integer has a value of 2 so the addition is 2+2=4.

Part c: As the scoping is dynamic with shallow binding, the x integer has a value of 1 so it will print 1.

4 0
3 years ago
Select all the correct answers.
Rasek [7]

Answer:

number formatting,

scientific analysis computer programming

6 0
3 years ago
(1)(50%) The program converts a three-ASCII-digit number to an 8-bit unsigned binary. For example, a 3-digit number as ‘0’ (=$30
MatroZZZ [7]

Answer:

Explanation:

3 - digit number                                             8 - bit binary

0 (=$30), 1 (=$31), & 8 (=$38)                          00010010

1 (=$31), 2 (=$32), & 9 (=$39)                          10000001

2 (=$32), 3(=$33), & 0 (=$40)                          11100110

2 (=$32), 4 (=$34), & 1 (=$41)                           11110001

2 (=$32), 5 (=$35), & 2 (=$42)                           11111100

2 (=$32), 5 (=$35), & 3 (=$ 43)                           11111101

2 (=$32), 5 (=$35), & 4 (=$44)                            11111110

2 (=$32), 5 (=$35), & 5 (=$45)                            11111111              

8 0
2 years ago
Other questions:
  • Write a program that reads three whole numbers and displays the average of the three number. Sample Run #: java Average3 Interac
    15·1 answer
  • To create a file in dos edit, type ____ at the command prompt to start dos edit, and then begin typing in the document window.
    8·1 answer
  • Select the correct answer.
    7·2 answers
  • Reasons for the growth of decision-making systems include:
    13·1 answer
  • Give an example of a file suffix for the files created by each of the following: 1) a word processing program 2) a spread sheet
    14·1 answer
  • Categorize each of the following situations as a compile-time error, run-time error, or logical error. Group of answer choices m
    5·1 answer
  • In a networking context, "architecture" refers to
    5·1 answer
  • What is true about the dilation?
    6·2 answers
  • How do cyber criminals target user’s end devices?
    11·2 answers
  • in this third journal assignment, you will think about your work as the product tester for the travel booking software and how y
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!