I am new in java.
I should use System.in.read() to solve my program
but I don't know ,what does it exactly do?
thanks for helping
my question :
take a number of user. If the number is less than 1, print an error. Otherwise, print the result of 2 ^ ( 1 incoming number ) . "Once with for AND Once with while "
'int i ;
int num ;
System.out.println("enter a number : ");
for (i=1 ; (num = System.in.read()) != '\r' ; i++ )
{
if( num <1 )
{
System.out.println("illegal value! \n enter a number");
}
else
{
int j; int pow = 1;
for (j = 1 ; j <= num ; j++)
{
pow *=2 ;
System.out.println(pow);
}
}
}`