Welcome to Dream.In.Code
Getting Java Help is Easy!

Join 136,406 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 2,471 people online right now. Registration is fast and FREE... Join Now!




What is the Problem for binary change to hexadecimal?

 
Reply to this topicStart new topic

What is the Problem for binary change to hexadecimal?

yooxygen
2 Sep, 2008 - 05:55 PM
Post #1

New D.I.C Head
*

Joined: 20 Jan, 2008
Posts: 15


My Contributions
CODE

import java.util.*;

class Hexadecimal
{
    static Scanner sc= new Scanner (System.in);
    
    public static void main(String[] args)
    {
        String Decimal;
      
        int a,y;
        int [] num= new int[2];
        
      
    {
        System.out.print("Enter a integer: ");
        Decimal= sc.nextLine();
        
        int x= Integer.parseInt(Decimal);
                
        a=0;
        while(x!=0)  
        {  
           y=x%16;  
           x=x/16;  
           num[a]=y;  
           a++;  
        }
        a--;
        
        if (x==num[a]+num[a-1])
        {
           swtich(num[a]+num[a-1]);
           {
            
            case 10:                            //it say tat orphaned case
            System.out.print("A");
            break;
            case 11:
            System.out.print("B");
            break;
            case 12:
            System.out.print("C");
            break;
            case 13:
            System.out.print("D");
            break;
            case 14:
            System.out.print("E");
            break;
            case 15:
            System.out.print("F");
            
        }
    }
        
      
        System.out.print("The hexadecimal form is ");
        for(;a>=0;a--)
        {
            System.out.print(num[a]);
        }
        System.out.println();
    }
}
}



wat mean of orphaned case??
n izit the array can add like tat??
thx for helping... rolleyes.gif
User is offlineProfile CardPM
+Quote Post

Locke37
RE: What Is The Problem For Binary Change To Hexadecimal?
2 Sep, 2008 - 06:02 PM
Post #2

I'm not a thief...I prefer the term TREASURE HUNTER!
Group Icon

Joined: 20 Mar, 2008
Posts: 1,005



Thanked: 39 times
Dream Kudos: 325
My Contributions
You typed swtich instead of switch.

I believe that will give you that error.
User is online!Profile CardPM
+Quote Post

yooxygen
RE: What Is The Problem For Binary Change To Hexadecimal?
2 Sep, 2008 - 06:12 PM
Post #3

New D.I.C Head
*

Joined: 20 Jan, 2008
Posts: 15


My Contributions
QUOTE(Locke37 @ 2 Sep, 2008 - 07:02 PM) *

You typed swtich instead of switch.

I believe that will give you that error.



oic...din notice...thx biggrin.gif
User is offlineProfile CardPM
+Quote Post

Locke37
RE: What Is The Problem For Binary Change To Hexadecimal?
2 Sep, 2008 - 06:14 PM
Post #4

I'm not a thief...I prefer the term TREASURE HUNTER!
Group Icon

Joined: 20 Mar, 2008
Posts: 1,005



Thanked: 39 times
Dream Kudos: 325
My Contributions
No problem! Glad I could help! smile.gif
User is online!Profile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 12:05PM

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month