what i am trying to do here. is to let the user type a hexadecimal number

http://en.wikipedia.org/wiki/Hexadecimal

and then display it.

import java.io.*;
class Ex23
{
          public static void main(String[] args)
          {
           Console console=System.console();
           System.out.println("please type a hexadecimal number");
           String input;
           input=console.readLine();
           int number;
           int number=Integer.parseInt(input);
           int count=0;
           char c= input.charAt(0);
           c= console.readline(input);           
           String abc= "abcdef";
           
           
           if(c!=number)
             
                while(c==abc.charAt(count))
                 {
                 number2=count+9;
                 count++;}
                      
                System.out.println(number2);
            
           else
            
                System.out.pringln(number);
           
         
         }
}

it tells me that there is an else with no if.. why is that?

Recommended Answers

All 2 Replies

Recheck you code. The braces are not complete.

it tells me that there is an else with no if.. why is that?

Always use braces ({}) with your if,else, while, for ... statements as mentioned by the Sun Java coding conventions and you will be able to spot your error.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.