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]
4 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]4 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
Which of the below statements describes the nature of HTML elements - check as many as apply
slava [35]

Answer:

The answer to this question is option 1,2 and 4.

Explanation:

Some html elements does not contain anything or having no content are called empty html elements.for ex:- <br>,<hr> etc.

HTML elements are of two types block and inline.block elements starts with new line for ex:-div,body etc.Inline elements does not starts with new line.for ex:-<style>,<meta>,<head>etc.

Html elements also contains attributes that modify the element for ex:-

<body style="background-color:blue;">

where style is an attribute.

5 0
3 years ago
¿que significa “TTAQMMQMPDATLSPLNDTMGCCLFEQMMPQTEIUMDR” ?
OlgaM077 [116]

Answer: what

Explanation:

5 0
3 years ago
Read 2 more answers
Production cost can be reduced using technology. Explain
Black_prince [1.1K]

Explanation:

By reducing the time the use on unnecessary tasks. And you would be able to operate on using your time on beneficial tasks

3 0
3 years ago
Who do you understand by term DATA give example? please give answer in own words​
xeze [42]

Answer:

The term data is simply defined as “facts and figures”. Each piece of data is a little fact that doesn't mean much on its own. The word data can be used for a singular fact or a collection of facts. It comes from the Latin word datum, meaning “something given”.Data is defined as facts or figures, or information that's stored in or used by a computer. An example of data is information collected for a research paper. An example of data is an email. ... Statistics or other information represented in a form suitable for processing by computer.

4 0
3 years ago
Read 2 more answers
Which type of data is generally stored in different file formats, such as text files, spreadsheets, and so on?
zepelin [54]

Answer:

Plain text storage (eg, CSV, TSV files)

Sequence Files.

Avro.

Parquet.

3 0
3 years ago
Read 2 more answers
Other questions:
  • What of the following google tools support collaboration
    10·1 answer
  • Which occupation requires certification by the state?
    15·2 answers
  • The ______ is the information center that drivers need to refer to when they're NOT scanning the road.
    13·1 answer
  • A _____ is a unique name that identifies an Internet site. URL Browser AOL IA
    13·1 answer
  • One blog may have a greater social influence than another when it has_______?
    12·2 answers
  • You will implement three different types of FFs with two different reset types. You have to show your results on your FPGA. You
    9·1 answer
  • How was the Big Ben project similar to the investigation you conducted in class to determine if the table was vibrating? How is
    7·1 answer
  • For each of the descriptions below, perform the following tasks:
    11·1 answer
  • Help a brotha out..................
    10·1 answer
  • What is the basic body structure of html.
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!