sorry for not posting my problem briefly,actually sir. its not my only problem..
ill post the code
import java.io.*;
public class Main
{
private static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
public static void main(String[] args)throws IOException
{
String number1,number2,number3;
int num1,num2,num3,decimalPlaces=0;
System.out.print("Enter a number : ");
number1=br.readLine();
num1=Integer.parseInt(number1);
System.out.print("Enter the second number : ");
number2=br.readLine();
num2=Integer.parseInt(number2);
System.out.print("Enter the third number : ");
number3=br.readLine();
num3=Integer.parseInt(number3);
if
(num<=9) /* this part is running perfectly down to the
decimalPlaces=decimalPlaces+1; third condition,if the number is <=999
*/
else if
(num1<=99)
decimalPlaces=decimalPlaces+1;
else if
(num1<=999)
decimalPlaces=decimalPlaces+2;
else
System.out.println("Cannot proceed");
System.out.print("The first number has "+decimalPlaces+" decimalplaces");
}
}
the program is totally running it doesnt have syntax erros
but the problem is ,its not running the way i expect to.
the first three condition is running perfectly as i want to.. but in the last condition,
if i entered number below 0 (negative numbers), it prints the condition ("CANNOT PROCEED")
BUT IT ALSO PRINTS THE OTHER STRING ("the first number has " +decimalPlaces + " ");
the only thing that i want to happen is this
if i entered positive numbers then it will print the decimal places according to the condition that i make ,and it will print the string ("The first number has " +decimalPlaces+ " son on...");
but if i entered negative numbers , the last condition will automatically do its job and print ONLY the string ("CANNOT PROCEED");
just having some structure problem here..
anyway sir.. tnx !!