User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 455,965 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,655 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 2321 | Replies: 22 | Solved
Reply
Join Date: Feb 2006
Posts: 1,508
Reputation: masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light 
Rep Power: 10
Solved Threads: 136
masijade's Avatar
masijade masijade is online now Online
Posting Virtuoso

Re: Weird Binary to Integer Problem

  #11  
Nov 18th, 2007
Originally Posted by rpk5000 View Post
Yes I do know that a boolean array is an array of booleans, but when you said binary array, I wasn't sure if you meant the array of integers, as I've never actually heard of a "binary" array. In the op the text I copy and pasted seems to refer to an array of booleans, while the test data hes provided (http://www.shenet.org/high/hsacaddep...od%20Pract.pdf) here, (problem n, seems to show the input as an int.


He refered to it as a "binary aray" because that is essentially what a boolean array is. Binary is 1 or 0, boolean is true or false. So, in the sense of this homework assignment, that boolean array is a binary array. Each boolean array element is one bit in the binary sequence.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote  
Join Date: Apr 2007
Location: US
Posts: 21
Reputation: rpk5000 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
rpk5000 rpk5000 is offline Offline
Newbie Poster

Re: Weird Binary to Integer Problem

  #12  
Nov 18th, 2007
And no this is not just a rude comment. You posted your homework assignment, almost word for word it looks like, without giving any indication that you had done anything at all. What is anyone supposed to infer from that other than "Do my homework for me"? Next time, post the work you have already done when you open the thread and you can avoid the accusations.

Almost word for word.... thats my issue, I'm confused by the wording of the assignment...

As to it looking like I wanted you to do it for me...

This is part of a methods practice assignment I was given. I'm currently taking AP Comp Sci.

I'm not sure what my teacher wants me to do. (I don't think I'll have a problem actually doing it once I know what he wants)

...

Writing a binary to decimal converter would be easy, I'm not sure what he means by the stuff in the second sentence though.

Next time, don't make poor assumptions and you would avoid looking like an idiot?
Don't take your anger out on me because you didn't read the question and are suddenly surprised when someone points that out.

He referred to it as a "binary array" because that is essentially what a boolean array is. Binary is 1 or 0, boolean is true or false.

Yes I get that.

So, in the sense of this homework assignment, that boolean array is a binary array. Each boolean array element is one bit in the binary sequence.

Everyone keeps mentioning a boolean array, where the heck is it? Or, am I already done and the bit about boolean arrays in the problem wasn't necessary to solving it?
Reply With Quote  
Join Date: Feb 2006
Posts: 1,508
Reputation: masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light 
Rep Power: 10
Solved Threads: 136
masijade's Avatar
masijade masijade is online now Online
Posting Virtuoso

Re: Weird Binary to Integer Problem

  #13  
Nov 18th, 2007
Originally Posted by rpk5000 View Post
Almost word for word.... thats my issue, I'm confused by the wording of the assignment...

As to it looking like I wanted you to do it for me...



Next time, don't make poor assumptions and you would avoid looking like an idiot?
Don't take your anger out on me because you didn't read the question and are suddenly surprised when someone points that out.

No where in that first post did you give any indication of having done any work. Made a lot of statements about "I thought" "I tried" but didn't show any of that effort, and it's easy to claim. So it was still nothing but a "do my work for me" post. And the only one looking like an idiot is you doing your "I didn't say that" backpedaling.

Everyone keeps mentioning a boolean array, where the heck is it? Or, am I already done and the bit about boolean arrays in the problem wasn't necessary to solving it?


You mentioned the boolean array, here the quote from your first post The binary number will be passed in as an array of Booleans (a true represents a 1 and a false represents a 0.).
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote  
Join Date: Nov 2007
Posts: 30
Reputation: InfiNate is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 6
InfiNate InfiNate is offline Offline
Light Poster

Re: Weird Binary to Integer Problem

  #14  
Nov 18th, 2007
Perhaps you should clarify with your teacher since the only thing you are confused with is his wording.

FWIW my definition of a boolean array would be:
bool[] boolArray;
Which.. as I said before, is an array of booleans.
Reply With Quote  
Join Date: Apr 2007
Location: US
Posts: 21
Reputation: rpk5000 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
rpk5000 rpk5000 is offline Offline
Newbie Poster

Re: Weird Binary to Integer Problem

  #15  
Nov 18th, 2007
I did, I sent an email to him yesterday.


No where in that first post did you give any indication of having done any work. Made a lot of statements about "I thought" "I tried" but didn't show any of that effort, and it's easy to claim. So it was still nothing but a "do my work for me" post. And the only one looking like an idiot is you doing your "I didn't say that" backpedaling.

You can't edit your posts here (or at least not that I'm aware of) so I don't need to further point out whats wrong with your comments, I'll just let people review them and come up with their own opinion.

You mentioned the boolean array, here the quote from your first post The binary number will be passed in as an array of Booleans (a true represents a 1 and a false represents a 0.).

That line is the problem (ie, what the assignment was). The whole conversation has been about what that line means. Since you missed that, I'd prefer that you would remain out of the thread, until you calm down or have something to contribute.
Reply With Quote  
Join Date: Mar 2006
Location: Yorkshire, UK
Posts: 2,909
Reputation: happygeek is an unknown quantity at this point 
Rep Power: 8
Solved Threads: 7
Admin
Staff Writer
Featured Blogger
happygeek's Avatar
happygeek happygeek is online now Online
He's The Daddy

Re: Weird Binary to Integer Problem

  #16  
Nov 18th, 2007
C'mon guys, cool down - let's just have a virtual handshake and a beer and start again, marking this one down to misunderstanding...
Davey Winder
Information Security Journalist of the Year (2008)
www.happygeek.com
Author: Being Virtual
Reply With Quote  
Join Date: Apr 2007
Location: US
Posts: 21
Reputation: rpk5000 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
rpk5000 rpk5000 is offline Offline
Newbie Poster

Re: Weird Binary to Integer Problem

  #17  
Nov 18th, 2007
I can't have beer but my teacher finally replied and said that reading in as a string would be fine...
Reply With Quote  
Join Date: Feb 2006
Posts: 1,508
Reputation: masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light 
Rep Power: 10
Solved Threads: 136
masijade's Avatar
masijade masijade is online now Online
Posting Virtuoso

Re: Weird Binary to Integer Problem

  #18  
Nov 18th, 2007
Whatever. Continue on in your world of percieved slights. I'm not the one here asking for help.

You know what they say about biting the hand that feeds you.

And, you can prefer anything you wish, not that you can make it come true.

Edit: But, it's fairly obvious that you read in the number anyway you want to, and create the "binary array" from the read string (I assume from that snippet that you read the "number" already in binary format) and pass that array to the method that is to do the conversion. It is kind of hard for your program to receive the input as an array already already (unless it is to read it over a socket using an ObjectIputStream or something, which is beyond the current class objectives, I would assume) so it should also be fairly obvious that you need to create the argument you pass to the array from whatever you read in, reagardless of how you read it in, so, I don't see what has been giving you a problem.
Last edited by masijade : Nov 18th, 2007 at 11:22 pm.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote  
Join Date: Apr 2007
Location: US
Posts: 21
Reputation: rpk5000 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
rpk5000 rpk5000 is offline Offline
Newbie Poster

Re: Weird Binary to Integer Problem

  #19  
Nov 18th, 2007
Heres what my problem was:
"The binary number will be passed in as an array of Booleans"

I couldn't understand why in the world you would pass in an array of booleans. I think about booleans as ... booleans... true/false values. So why would someone enter: TrueFalseTrueFalse... or something like that. In his email back, he told me that reading it in as an int or string was fine. The sentence also conflicted with the test data, which gave the binary number as a binary value (eg:. 1001, 11001). When he said array of booleans, he really meant an array of any valid type that could store 1-0 values.
Reply With Quote  
Join Date: Feb 2006
Posts: 1,508
Reputation: masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light 
Rep Power: 10
Solved Threads: 136
masijade's Avatar
masijade masijade is online now Online
Posting Virtuoso

Re: Weird Binary to Integer Problem

  #20  
Nov 18th, 2007
Okay, I will try to say this nicely.

Given that the data to be read is 1001,11001, etc and given the text The binary number will be passed in as an array of Booleans (a true represents a 1 and a false represents a 0) it seems faairly obvious that you need to create the binary array yourself. It's a stupid requirement, yes, but that's the way the world is. I've seen requirements much worse in real projects.

Now, maybe it's just me, but that all seems to be glaringly obvious, so your first post said to me (reading between the lines), "write (at least this part of) the program for me". Which was the reason for my first post. I apologize if that was not the case, but that is the way I interpreted the first post (and we get that here so often it has become the norm, rather than the exception).

But, in any case, read in the String, create a boolean array of the same length as the String, then loop over the String setting each element in the array according to the requirements provided in the assignment text. (Really, you only need to worry about the ones, as a boolean array is initiated with all elements false, which is how 0 is to be represented.)

Edit: And a boolean is, yes, a boolean. But, what is a boolean? It is a switch, an "either/or", in other words, which is also exactly what a bit is. It uses 1/0 as the textual representation, whereas a boolean uses true/false, but they mean the same thing, on/off or used/free. That is another way of seeing a boolean, and what, I believe, is meant here.
Last edited by masijade : Nov 18th, 2007 at 11:58 pm.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Java Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 9:05 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC