import java.util.*; public class ConversionofBinarytoDecimalandDecimaltoBinary { public static void main(String[] args) { Scanner keyboardin = new Scanner(System.in); int option; String binary; //REPEAT WHILE Option is not '3' do{ //DISPLAY menu displayMenu();//call the method displayMenu System.out.print("Select conversion type: "); option = keyboardin.nextInt(); switch(option) { case 1:System.out.println("Binary to Decimal"); System.out.print("Enter Valid Binary number: "); binary = keyboardin.next(); break; case 2:System.out.println("Decimal to Binary"); System.out.println("Enter Decimal number:"); break; case 3:System.out.println("you have finished your conversions"); break; default:System.out.println("invalid menu option chosen"); break; }//end switch }while(option!= 3); }//end main public static void displayMenu() { System.out.println("1. Binary to Decimal"); System.out.println("2. Decimal to Binary"); System.out.println("3. Quit"); }//end method }//end class

Binary to decimal

import java.util.*; public class BinaryToDecimal { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); //number input by user String binary; String number; //value of binary number int binValue = 0; System.out.print("Enter a valid binary number:"); binary = keyboard.next(); //find length of number int length = binary.length(); for (int counter = 0; counter<=length; counter++){ //Calculations for each one in the binary number if (number = 1) { binValue = binValue +(2^counter); } //re-prompt if the number contains anything other than ones and zeros (Invalid binary number) else{ System.out.println(binary + " is not a valid binary number."); System.out.print("Enter a valid binary number:"); binary = keyboard.next(); } } System.out.println("The decimal value of " + binary + "is: " + binValue); } }

Decimal to binary

import java.util.*; public class ConversionofDecimaltoBinary { public static void main(String[] args) { Scanner keyboardin = new Scanner(System.in); int [] output = new int [32]; int x; int digit; int base =2; int digitno =0; x = keyboardin.nextInt(); while (x>0) { digit = x%base; output[digitno] = digit; digitno++; x = x%base; for(int i = digitno - 1; i>=0; i--); System.out.println(digit[i]); } } }

I have been trying to do this over the last two days and seem to be making no progress and I'm not even sure if I'm even going about the conversion ways the right way, so any help would be appreciated.