Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

help needed for logic building

  Asked By: Hayfa    Date: Nov 06    Category: Java    Views: 2003
  

I am working as systems administrator in Delhi, but want to shift to java
programming. So I am working on core java now-a-days from Phillips Heller's
Study Guide.

Recently I appeared in an interview, and the interviewer asked me to make a
programming to convert a decimal no. to binary. But unfortunately I could do
that. So I was not selected in the first round.

I really want to get in to java and I am looking for some resources on the
internet which could help me in building my logic.

Friends, if you could tell me some resources or tell me some programs like
binary conversion, octal conversion or hex conversion, or may be some matrix
multiplication etc. then it would be great.

I am looking for such type of questions for some time now but could not find
some good resource on that.

Share: 

 

6 Answers Found

 
Answer #1    Answered By: Jezza Brown     Answered On: Nov 06

your problem has nothing to do with Delphi, Java, or any other
language. You have a fundamental task to solve. Which is called:
thinking like a programmer.

What I mean is the following: you have been asked  to convert  a
decimal number (that is, a string consisting of digits 0 through 9)
to a binary  number. This is a very basic task to be performed by
every compiler and every computer application. Or what do you think
does a compiler do when it encounters something like this?
IntVar := 2;

Correct me if I'm wrong, but I think you don't know how to accomplish
this task at all. And that's programmer's basic knowledge. It works
like this:
Suppose you have an integer number n given in base k; that means you
have a string of digits in the range 0 through k-1; for a decimal
number (base 10) it is you have a string of digits ranging from 0
through 9 (which is 10 - 1).
You have to convert this number to base m (different from k); that
means you have to generate a string of digits in range 0 through m-1.

In your example this means you have to convert a decimal  number (base
10) to a binary number which has base 2. The way you do it for
integer numbers is (I'll give the algorithm in some Pascal-like
style):

help_var := n;
Str_result := '';
while help_var != 0 do
digit := help_var mod m;
help_var := help_var / m;
Comment: This ^^ is an integer division!
Str_Result := Str_Result + Chr( 48 + digit);
Comment: this assumes that you're using ASCII codes
where '0' = Chr(48) and '9' = Chr(57).
end while;
Reverse( Str_Result);
WriteLn( Str_Result);

I hope you get what I mean regarding programmers' basics. No offence
meant.

If the algorithm is unclear, please ask again.

As to your question about such basic questions:
1) try Kernighan & Ritchie, "ANSI C"; they have loads of examples.
Even if you don't want to learn C these examples will help  you to get
some feeling for programming.
2) Read Donald Knuth, The Art Of Computer Programming. All three
volumes. I know, it's a lot of hard stuff, but if you've read this
and worked through the examples you'll have gained more experience
than most programmers I've ever met. Honestly.

 
Answer #2    Answered By: Norman Ray     Answered On: Nov 06

Nice to hear from you, but look my dear, when ever I just going thru ur posting,
I was unable to stop laugh for stupid question..

If a fellow, who knows the basic mathematics can able to convert  this. However
first and foremost dont think in Java way as Mr Nico told , think in general way
and then try to achieve that in specific langauge ....

 
Answer #3    Answered By: Leon Evans     Answered On: Nov 06

this is a BAD posting. Stop behaving like that.
Why?
Very easy: imagine instead of Kapil a 14-year-old boy writes such a
posting. Because he's curious to learn programming. O.k., in this
case Kapil said he's been working  as a sys admin, but in other cases
you may have a question from someone who can't have the knowledge
and/or experience to know better. And postings such as yours will
surely keep this poor chap from asking again. Do you see what your
behaviour leads to? You will keep people from asking because they
don't like being offended like this.

Yes, I consider your posting offensive. You should honestly
reconsider your behaviour. Or stop answering to such questions, if
you want to behave like that. Be glad that I'm not the moderator of
this group, otherwise this post from me would be the first and last
warning: stop your mean, unkind, and discouraging behaviour, or I'll
ban you.
Now I am _not_ the moderator, so even if I wanted to, I couldn't do
that. But your behaviour is really worth some consideration. I don't
ask you to be ashamed of yourself; just think about how you want to
be treated, and then treat other people in the way you want to be
treated. I assume you prefer to be treated kindly and honestly, don't
you? So treat other people the same way, not haughty.

 
Answer #4    Answered By: Garai Chalthoum     Answered On: Nov 06

I don intend to ashame or discourage the people who is
working as system administrator and asking for the
logic to number system conversion.

Do u feel, this is the query affored to post on the
groups instead of 2 minutes thinking,

that query is funny to me not the guy who is asking
it, okay????

 
Answer #5    Answered By: Caitlin Brown     Answered On: Nov 06

First of all, I would like to thank you for understanding my problem and giving
me advise to read Ritchie's book and "The Art of Computer programming". I will
def. read these books to improve my knowledge for programming logic.

Well, Hari, you know Nico is very right that your way was quite discouraging to
answer like that. You really need to work on your behaviour with others. Because
if you want to be liked by others then you should not laugh at others, instead
guide them to learn the right things.

Well, I am not a 14-year old boy, who will be discouraged with such an answer.
But, if there would be someone else of younger age, it would be very
discouraging for him.

Well, I wish you luck for changing your attitude towards others and try to be
and encouraging person.

 
Answer #6    Answered By: Mamie Wallace     Answered On: Nov 06

You correctly identified my problem, I need to work on programmers basics first
only then I can get in to a programmers job.

Your suggestions of the books are really great, I already have Ritchie's book
and I will try to arrange "The Art of Computer Programming".

 
Didn't find what you were looking for? Find more on help needed for logic building Or get search suggestion and latest updates.




Tagged: