menu
Qamnty
Login
Register
My account
Edit my Profile
Private messages
My favorites
Consider the following recursive method, which is intended to display the binary equivalent of a decimal number. For example, toBinary(100) should display 1100100. public static…
Ask a Question
Questions
Unanswered
Tags
Ask a Question
Consider the following recursive method, which is intended to display the binary equivalent of a decimal number. For example, toBinary(100) should display 1100100. public static…
asked
Jan 13, 2022
58.5k
views
2
votes
Consider the following recursive method, which is intended to display the binary equivalent of a decimal number. For example, toBinary(100) should display 1100100.
public static void toBinary(int num)
{
if (num < 2)
{
System.out.print(num);
}
else
{
/* missing code */
}
}
Which of the following can replace /* missing code */ so that toBinary works as intended?
a. System.out.print(num % 2);
toBinary(num / 2);
b. System.out.print(num / 2);
toBinary(num % 2);
c. toBinary(num % 2);
System.out.print(num / 2);
d. toBinary(num / 2);
System.out.print(num % 2);
e. toBinary(num / 2);
System.out.print(num / 2);
Computers & Tech
college
SimonAlfie
asked
by
SimonAlfie
7.5k
points
answer
comment
share this
share
0 Comments
Please
log in
or
register
to add a comment.
Please
log in
or
register
to answer this question.
1
Answer
0
votes
Answer:
D) toBinary(num / 2);
System.out.print(num % 2);
Step-by-step explanation:
David Hanak
answered
Jan 18, 2022
by
David Hanak
8.4k
points
ask related question
comment
share this
0 Comments
Please
log in
or
register
to add a comment.
← Prev Question
Next Question →
Related questions
asked
Jul 20, 2022
18.9k
views
public class Exercise_07 { public static void main(String[] args) { System.out.println(bin2Dec("1100100")); // Purposely throwing an exception... System.out.println(bin2Dec("lafkja")); } public static
Fastobject
asked
Jul 20, 2022
by
Fastobject
7.8k
points
Computers & Tech
college
2
answers
3
votes
18.9k
views
asked
Mar 15, 2020
75.7k
views
Write a method named toBinary that accepts an integer as a parameter and returns a string of that number's representation in binary. For example, the call of toBinary(42) should return "101010".
Zvone
asked
Mar 15, 2020
by
Zvone
8.1k
points
Computers & Tech
high-school
1
answer
2
votes
75.7k
views
asked
Sep 26, 2024
167k
views
55% of what number is 1100? Which of the following proportions could be used to solve this problem? A: 55100=x110055100=x1100 B: 55100=1100x55100=1100x C: 551100=100x551100=100x D: 55x=110010055x=1100100
Ravi Ashara
asked
Sep 26, 2024
by
Ravi Ashara
9.0k
points
Mathematics
high-school
1
answer
0
votes
167k
views
Ask a Question
Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.
Categories
All categories
Mathematics
(3.7m)
History
(955k)
English
(903k)
Biology
(716k)
Chemistry
(440k)
Physics
(405k)
Social Studies
(564k)
Advanced Placement
(27.5k)
SAT
(19.1k)
Geography
(146k)
Health
(283k)
Arts
(107k)
Business
(468k)
Computers & Tech
(195k)
French
(33.9k)
German
(4.9k)
Spanish
(174k)
Medicine
(125k)
Law
(53.4k)
Engineering
(74.2k)
Other Questions
“What does it mean when we “rework” copyrighted material?”
The book shows how to add and subtract binary and decimal numbers. However, other numbering systems are also very popular when dealing with computers. The octal (base 8) numbering system is one of these.
Seven basic internal components found in a computer tower
Twitter
WhatsApp
Facebook
Reddit
LinkedIn
Email
Link Copied!
Copy
Search Qamnty