Flash Website Builder- Trendy Site Builder is a Flash Site Building tool that helps users build stunning websites. Check Out Custom Custom Logo Design by LogoBee. Website Design and Free Logo Templates available.
 CodingForums.com java, cant figure this out

Before you post, read our: Rules & Posting Guidelines

Enjoy an ad free experience by logging in. Not a member yet? Register.
 02-23-2006, 07:11 AM PM User | #1 Uber Fr0g New Coder   Join Date: Feb 2006 Posts: 11 Thanks: 0 Thanked 0 Times in 0 Posts java, cant figure this out i have the deitel 6th edition how to program java book. On page 227 example 5.12 it says: "Write an application that calculates the prduct of the odd integers from 1 to 15." That is all it says...does it mean multiply all the odd numbers from 1 to 15? If so how do i do this....im not sure how to point out negative numbers.
 02-23-2006, 02:26 PM PM User | #2 Spookster Supreme Overlord     Join Date: May 2002 Location: Marion, IA USA Posts: 6,264 Thanks: 4 Thanked 83 Times in 82 Posts I'd probably get clarification from your teacher on that one. It can be interpreted a few different ways. My interpretation would be that you need to come up with an algorithm to compute the product for every combination of odd integers from 1 - 15. Obviously you wouldn't manually write out every combination so that means you need one or more loops and some code to determine if the two integers are odd and then multiply them together and do so for every combination of odd integers. So for example you want to: 1x1 = 1 1x3 = 3 1x5 = 5 1x7 = 7 1x9 = 9 1x11 = 11 1x13 = 13 1x15 = 15 3x1 = 3 3x3 = 9 3x5 = 15 . . . until you get to 15x15 = 225 Another question would be if it wants you to exclude duplicate calculations. Obviously you would have already done 1x3 so do you need to also include 3x1. __________________ Spookster CodingForums Supreme Overlord All Hail Spookster
 02-23-2006, 02:56 PM PM User | #3 NancyJ Senior Coder     Join Date: Feb 2005 Location: Bradford, UK Posts: 3,165 Thanks: 19 Thanked 65 Times in 64 Posts I would guess it means 1x3x5x7x9x11x13x15. Technically thats what its asking, if it wanted spooksters example it should have said 'products' as you end up with multiple answers. Ofcourse what a question asks for and what it wants are not always the same thing I'm assuming the book has answers in it too? If so, ask a friend to look up the answer. __________________ http://www.hazelryan.co.uk
 02-23-2006, 03:27 PM PM User | #4 Ender New Coder   Join Date: Feb 2006 Location: US Posts: 33 Thanks: 0 Thanked 0 Times in 0 Posts Code: int product = 1; for (int i = 1; i <= 15, i+=2) product *= i; or you can do it recursively. Code: public int oddFactorial(int i) { if (i == 1) return 1; return i * oddFactorial(i-2); }
 02-23-2006, 05:13 PM PM User | #5 Uber Fr0g New Coder   Join Date: Feb 2006 Posts: 11 Thanks: 0 Thanked 0 Times in 0 Posts i tried both of those ways and cant seem to get either to work.
02-23-2006, 06:03 PM   PM User | #6
Spookster
Supreme Overlord

Join Date: May 2002
Location: Marion, IA USA
Posts: 6,264
Thanks: 4
Thanked 83 Times in 82 Posts
Quote:
 Originally Posted by Ender Code: int product = 1; for (int i = 1; i <= 15, i+=2) product *= i; or you can do it recursively. Code: public int oddFactorial(int i) { if (i == 1) return 1; return i * oddFactorial(i-2); }
Why would you just provide a solution to what likely is a homework assignment? They didn't ask for a solution. They asked for an explanation of what the book was asking. The book he/she is using is used in the classroom for programming courses and those questions are normally assigned for homework.
__________________
Spookster
CodingForums Supreme Overlord
All Hail Spookster

02-24-2006, 12:07 AM   PM User | #7
Ender
New Coder

Join Date: Feb 2006
Location: US
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
 Originally Posted by Uber Fr0g i tried both of those ways and cant seem to get either to work.
They do work. Can you not debug a comma? Learn to program.

Quote:
 Originally Posted by spookster Why would you just provide a solution to what likely is a homework assignment? They didn't ask for a solution. They asked for an explanation of what the book was asking. The book he/she is using is used in the classroom for programming courses and those questions are normally assigned for homework.
I'm sorry, I know I shouldn't have given solutions, as he obviously posted his homework. I don't know why I answered like that... partly because it was early in the morning and I had not gotten a lot of sleep, and partly because of strange, subconscious, contemptuous reasons.

 Bookmarks

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home :: Client side development     JavaScript programming         DOM and JSON scripting         Ajax and Design         JavaScript frameworks         Post a JavaScript     HTML & CSS     XML     Flash & ActionScript         Adobe Flex     Graphics and Multimedia discussions     General web building         Site reviews         Building for mobile devices :: Server side development     Apache configuration     Perl/ CGI     PHP         Post a PHP snippet     MySQL         Other Databases     Ruby & Ruby On Rails     ASP     ASP.NET     Java and JSP     Other server side languages/ issues         ColdFusion         Python :: Computing & Sciences     Computer Programming     Computer/PC discussions     Geek News and Humour Web Projects and Services Marketplace     Web Projects         Small projects (quick fixes and changes)         Medium projects (new script, new features, etc)         Large Projects (new web application, complex features etc)         Unknown sized projects (request quote)         Vacant job positions         Looking for work/ for hire         Project collaboration/ partnership         Paid work offers and requests (Now CLOSED)     Career, job, and business ideas or advice     Domains, Sites, and Designs for sale         Domains for sale         Websites for sale         Design templates and graphics for sale :: Other forums     Member Offers     Forum feedback and announcements

All times are GMT +1. The time now is 02:40 PM.