Question: can come one correct this code to be able to do this I keep getting 3 errors Lab 3 Part 1 Problem to solve: Convert

 can come one correct this code to be able to do

this I keep getting 3 errors Lab 3 Part 1 Problem to

can come one correct this code to be able to do this

solve: Convert a four character binary number to equivalent base ten representation

I keep getting 3 errors

Lab 3 Part 1 Problem to solve: Convert a four character binary number to equivalent base ten representation //import statement for Scanner class import java. util.Scanner; public class BinaryToDecimal \{ public static void main(String[] args) \{ //declare string variable to store user input for binary number String inputString; //declare char variables to store each individual character of the String inputString; char char3, char2, char 1 , char0; //declare byte variables to store the integer version of each char /ote that the integer data type that requires least amount of RAM is a byte byte byte3, byte2, byte1, byte 0 ; //declare integer variable to store base ten representation of the binary Number int decimalValue; //create Scanner object to read keyboard input Scanner keyboard = new Scanner (System. in); //use Scanner object to collect user input for the inputString //use Scanner object to collect user input for the inputString System.out.println("Use Scanner object to collect user input:"); System.out.print("Enter a four digit binary number (no spaces): "); inputString = keyboard.nextInt(); System.out.println("You entered: " + inputString); //decompose inputString into its individual chars char3 = inputString. charAt(); //cast each char to a string and then to a byte byte3 = Byte. parseByte(Character.toString(char3)); //Display the byte version of each char System.out.println("byte3: " + byte3 + "; byte2: " + byte2 +";byte1:"+byte1+";byte0:"+byte); //compute the base ten representation /ote that Math.pow ( ) returns a double, so this must be cast to an int //to permit storing result in an int //initialize decimalValue with the value of the left most digit decimalValue = byte 3 (int) Math.pow (2,3); //use combined assignment operator to increment decimalValue by value next //use combined assignment operator to increment decimalValue by value next digit; //use combined assignment operator to increment decimalValue by value next digit //display results to the user System.out.print("The base ten representation of " + inputString + " is: "); System.out.println(decimalValue); \} Use Scanner object to collect user input: Enter a four digit binary number (no spaces): 1011 You entered: 1011 byte3: 1 ; byte2: 0 ; byte1: 1 ; byte0: 1 The base ten representation of 1011 is: 11

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!