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
Butoxors [25]
3 years ago
11

Write a program that reads a 4-bit binary number from the keyboard as a string and then converts it into decimal. For example, i

f the input is 1100, the output should be 12. (Hint: Break the string into substrings and then convert each substring to a value for a single bit. If the bits are b0, b1, b2, and b3, the decimal equivalent is 8b0+ 4b1+ 2b2+ b3.)
Computers and Technology
1 answer:
adell [148]3 years ago
7 0

Answer:

import java.util.Scanner;

public class ss11{

       public static void main (String[]args) {

             Scanner keyboard = new Scanner (System.in)

             String a1, a2, a3, a4, a5;

              int i1, i2, i3, i4, i5;

              System.out.println("Enter a four bit binary number:");

               a1= keyboard.next();

               a2= a1.substring(0,1);

               a3= a1.substring(1,2);

               a4= a1.substring(2,3);

               a5= a1.substring(3,4);

                i1 = Integer.parseInt(a2);

                i2 = Integer.parseInt(a3);

                i3 = Integer.parseInt(a4);

                i4 = Integer.parseInt(a5);

                i1= i1 * 8;

                i2= i1 * 4;

                i3= i1 * 2;

                i4= i1 * 1;

                i5= i1+i2+i3+i4;

                System.out.println("The converted decimal number is: +i5);

}

}

Explanation:

You might be interested in
I need someone's opinion<br> Which format is better? The first or second one? I can't decide 0.0
Ne4ueva [31]

Answer:

2nd one

Explanation:

4 0
3 years ago
Read 2 more answers
The space between letters in a word is an example of what kind of space?
777dan777 [17]

Answer:

Explanation:

While the words are positive space, you have two kinds of negative space in text passage. Micro-space refers to the small spaces between letters and words. Macro-space, however, refers to the spaces between the big or major elements in a design, like the space between lines and columns of text.

4 0
3 years ago
Read 2 more answers
The proof that the Clique problem is NP-complete depends on a construction given in Theorem 34.11 (p. 1087), which reduces 3SAT
ki77a [65]

Answer:

Check the explanation

Explanation:

Kindly check the attached image below to see the step by step explanation to the question above.

5 0
3 years ago
Example of personal professional highlights of styles of communication
tankabanditka [31]
Mediocre skills required.
4 0
3 years ago
You are designing software for elderly people. Which two features can you
romanna [79]

give instructions in both text and audio formats

7 0
3 years ago
Other questions:
  • To insert a new slide in an existing presentation, what menu should you select?
    5·2 answers
  • Windows on the desktop are just one of many objects used in a graphical user interface (GUI)-- buttons, drop-down list boxes, po
    7·1 answer
  • When did mac start? when did windows start? when did lynux start?
    13·2 answers
  • the piece of hardware that contains the circuitry that processes the information coming in to the computer
    13·1 answer
  • What is the ability for a system to respond to unexpected failures or system crashes as the backup system immediately and automa
    8·1 answer
  • What is sum after the following loop terminates? int sum = 0; int item = 0; do { item ; sum = item; if (sum &gt; 4) break; } whi
    8·2 answers
  • In which situation is coauthoring of presentations primarily utilized?
    9·1 answer
  • Could anyone please answer this?
    15·1 answer
  • Web résumés allow you to include extra graphics and images that you would not include in a traditional résumé. Please select the
    12·1 answer
  • Suppose a program is operating with execution-time binding and the physical address generated is 300. the relocation register is
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!