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
How to revert a dismissed javascript popup alert box in chrome?
xeze [42]
When Google Chrome blocks pop-ups for you, the blocked pop-up alert icon <span>appears in the address bar. If you click on the icon, you can see the pop-ups that have been blocked for that page. If you'd like to allow pop-ups for that specific site:</span><span><span><span>
1. Click the pop-up alert icon  (in the address bar).</span>
</span><span>2. Click the link for the pop-up you'd like to see.
</span><span>3. To always see pop-ups for the site, select "Always show pop-ups from [site]." 

</span></span><span>If you'd like to proactively allow pop-ups for specific sites:
</span><span><span><span>1. Click the Chrome menu   in the top right hand corner of your browser.</span>
</span><span><span>2. Select Settings.</span>
</span><span><span>3. Click Show advanced settings</span>
</span><span><span>4. Under the "Privacy" section, click the Content settings button.</span>
</span><span>5. In the "Pop-ups" section, select "Do not allow any site to show pop-ups." 
</span>6. Click the 'Manage exceptions' button.
<span>7. Type in the url of the site that you'd like to allow pop-ups from.</span></span>
5 0
3 years ago
Choose the word that best completes this sentence. ____________ should cover every part of the worksite.
Evgen [1.6K]
Since you provide no choices, here are several things that should cover every part of the worksite :
- Emergency exit
- Safety measures

Hope this helps
5 0
3 years ago
Read 2 more answers
What property of semi-metals is useful in the computer industry?
artcher [175]
The answer is (a. Semi-conducting)
In the computer industry, semi-metals with a semiconducting property are useful in making of semiconductors. These metals have high resistance but lower than compare to insulators. This conductor could be crystalline or amorphous solids.
4 0
2 years ago
Write a method called classAttendence() that creates a 10-by-10 two-dimensional array and asks for user input to populate it wit
gladu [14]

Answer:

The method written in Java is as follows:

public static void classAttendance(){

   Scanner input = new Scanner(System.in);

   String[][] names = new String[10][10];

   for(int i =0;i<10;i++){

    for(int j =0;j<10;j++){

       System.out.print("Student Name: "+(i+1)+" , "+(j+1)+": ");

       names[i][j] = input.nextLine();        

    }  

   }

}

Explanation:

This defines the classAttendance() method

public static void classAttendance(){

   Scanner input = new Scanner(System.in);

This declares the 2D array of 10 by 10 dimension as string

   String[][] names = new String[10][10];

This iterates through the rows of the array

   for(int i =0;i<10;i++){

This iterates through the columns of the array

    for(int j =0;j<10;j++){

This prompts user for student name

       System.out.print("Student Name: "+(i+1)+" , "+(j+1)+": ");

This gets the student name from the user

       names[i][j] = input.nextLine();        

    }  

   }

The method ends here

}

<em>See attachment for complete program that include main method</em>

Download txt
6 0
2 years ago
Select all the correct answers.
gtnhenbr [62]

Answer:

If you want to learn coding than get a game and look at the code inside.

Explanation:

I sugest terraria

8 0
3 years ago
Other questions:
  • Which key on a laptop keyboard is often used to help pair a mobile device with another device for communication purposes?
    12·1 answer
  • What component on a smartphone requires pairing with another device?
    8·1 answer
  • Helppppppppppppppppppp
    11·1 answer
  • What do you call a set of programs?
    7·1 answer
  • 5. Which of the following views is used to run a PowerPoint presentation?
    11·2 answers
  • which of the following memory types cannot store the data for information permanently Ram chachi Flash Memory hard disk​
    8·1 answer
  • 2. Released in 1992, Street Fighter II, the revolutionary fighting game, was developed by which company?
    8·2 answers
  • What is the console.log function for?​
    13·1 answer
  • I NEED HELP, DO ASAP <br> Why do you have to adjust toys for different ages?
    11·2 answers
  • The best way to deal with crying children in the car is to ignore them or pull off the road
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!