im writing a program with input using System.in.read and when i imput a value no matter what it is the value that is returned is always 10.I'm not sure why but if someone can help me it would be greatly appreciated. I'm only allowed to use the System.in.read and
string methods. This is the code so far that i hafve written so if someone could look at it and tell me what im doing wrong it would be a big help. thanks. the problem seems to be with the S.O.P right after the first two while loops but there is probably something else wrong im jsut not sure what it is.
import java.io.*;
public class old3
{
public static void main(String[] args) throws IOException
{
int inputLine1[] = new int[72];
int inputLine2[] = new int[72];
String answer = "";
char number = 0;
char base = 0;
int line1 = 0, line2 = 0;
int remainder = 0;
System.out.print ("Please select a base from 2 to 36:");
base = (char)System.in.read();
while ( (base != 10) && (base != 13) )
{
inputLine1[line1] = base;
line1++;
base = (char)System.in.read();
}
base = (char)System.in.read();
System.out.println("The base selected is base "+(int)base );
System.out.print ("Please enter a number to be converted: ");
number = (char)System.in.read();
while ( (number != 10) && (number != 13) )
{
inputLine2[line2] = number;
line2++;
number = (char)System.in.read();
}
number = (char)System.in.read();
System.out.println("The number in base "+(int)base+ " is: "+(int)number);
if (number == 0)
answer = ("0");
while(number>0)
{
remainder=(number%base);
number= (char)((number-remainder)/base);
answer= remainder+answer;
}
System.out.print("The number in base "+(int)base + " is: "+ answer);
}
}e a big help. Thanks.