I made a program which converts binary with ft pt but cant get it work, what could be wrong here?
import java.io.*;
import java.util.Scanner;
public class NumberConverter
{
public static void main(String args[])throws Exception
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number: ");
String string_input = sc.nextLine();
double double_input = Double.parseDouble(string_input);
int int_input = (int)double_input;
float float_input = (float)(double_input - int_input);
int int_remainder;
float float_remainder;
String int_output = "";
String float_output = ".";
do
{
int_remainder = int_input % 2;
int_output = Integer.toString(int_remainder) + int_output;
int_input /= 2;
}while(int_input > 0);
do
{
float_remainder = float_input * 2;
if(float_remainder < 1)
{
float_output += "0";
}
else
{
float_output += "1";
float_input = float_remainder - 1.0f;
}
float_input *= 2;
}while(float_input > 0);
System.out.println(int_output + float_output);
}
}