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
2. A body is thrown vertically<br>100 m/s Theme taken to retum​
kondaur [170]

Answer:dead man lol roffle

Explanation:Not a gamer moment

6 0
3 years ago
Which sentences in the passage correctly describe a function?
quester [9]

Option D is correct.

Explanation :

  1. In option A, it is not mandatory that a function will have arguments and it will return a value.
  2. In option B, no formula begins with =.
  3. In option C, it is not necessary to begin with /.
  4. In option D, MAX function should return maximum value in the set given.

Thus, option D is correct because arguments of a function are always enclosed within parentheses

Example:

SUM (30,70)

8 0
3 years ago
A screen capture is a digital image of your screen, as if you took a picture of it with a camera. For instance, you might want t
GrogVix [38]

The given narration talks about the different means of taking a screen capture on a Windows environment.

<h3>What is a Screen Capture?</h3>

This refers to the process where the content of a screen is captured in a digital image form that is saved in the Documents of the computer as a screenshot.

Hence, we can see that the author mentioned the various ways of using the snipping tool to capture whole or part screens and the precise procedure on how to do it.

Read more about screen capture here:

brainly.com/question/22654940

#SPJ1

5 0
2 years ago
Antivirus software products require that you update _____ on a regular basis
german
Operating System, as far as I know @[email protected]
5 0
3 years ago
Read 2 more answers
Which graphics format works best for desktop publishing and print work? (1 point) .tiff .gif .tga .jpeg?
Sergeeva-Olga [200]
. jpeg, probably works best
6 0
2 years ago
Other questions:
  • Identify at least three body language messages that project a positive attitude?
    15·1 answer
  • Assume the existence of a Bank Account class. Define a subclass, Savings Account that contains the following: a double instance
    5·1 answer
  • Software that instructs the computer how to run applications and controls the display/keyboard is know as the
    8·1 answer
  • What is the meaning of the phrase the video has gone viral
    9·2 answers
  • Note: the println() function prints out a line of text with the value that you pass to it - so if you say println("Hi"), it will
    5·1 answer
  • An administrator has created a new custom object in a sandbox environment and now is ready to deploy in production. How can the
    11·1 answer
  • Jack lost all the data he saved on his desktop because of a power outage while working on a presentation. On which of these comp
    15·2 answers
  • Which scenarios are examples of students managing their time well? Check all that apply. A student studies while watching her fa
    8·2 answers
  • 12. When computer professionals take on jobs, they may not enter into relationships with which of the
    6·1 answer
  • MORE FREEE POINTS AYEEE
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!