Computer problems,Computer help
*AX SOFT>>>Programming & Design

Here's a riddle, and also a JCreator/Java Programing question.?


IF
every 3rd student is wearing a Hawaiian shirt
every 5th student is wearing sunglasses
every 8th student is bringing a camera
every 12th student is holding a Wall Street Journal.


How many students are waiting with a Hawaiian shirt, camera, sunglasses, and a copy of the Wall Street Journal?

i know the answer is student 120, 240, 360
but whats the math? need for java..

IF
there are 400 students.

every 3rd student is wearing a Hawaiian shirt
every 5th student is wearing sunglasses
every 8th student is bringing a camera
every 12th student is holding a Wall Street Journal.


How many students are waiting with a Hawaiian shirt, camera, sunglasses, and a copy of the Wall Street Journal?

i know the answer is student 120, 240, 360
but whats the math?! need for java..

Its the common multiple of all of them.

The condition works for all students in that position.
Ex.
The 1st 5th student will have sunglasses.
The 4th 5th student will also have sunglasses (4th 5th is the 20th student by the way).

The 12th student is just the 4th 3rd student, so ignore him for a minute.

We need to know the common point for all the conditions. Because 3* 8 is 24 Every 24th student will have a camera and a hawaiian shirt. And because every every 5th student will have sunglasses the 5th 24th student (number 120) will have a camera a hawaiian shirt and sunglasses.

We know that this student will also hold a wall street journal be cause the 24th student is also the 2nd 12th student.

Thus all four will occur in students on a multiple of 120.

In java the number of students with all four is integer division of the number of total students and the least common multiple of the conditions.

In this case:
answer = (int) 400 / 120

Use the mod operator.

loop students 1 - 400
if(students%3==0) Hawaiian shirt
if(students%5==0) sunglasses

To do all of them
if(students%3==0 && students%5==0 &&... etc
studentcount++;

lowest common multiple (remember from jr. high math class <^_^>).

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

Tags
  General - Computers & Internet   Software   Security   Programming & Design   Facebook   Flickr   Google   MSN   MySpace
Related information
  • Creating a Gadge on Windows Vista.?

    You can make gadgets????????? Cool, I was wonderin why they had no good ones to download

    ...
  • Do i hav to jail break my ipod touch to get ibeer and all those other apps?

    Yeah You Have To Jailbreak It. Its Actually Really Simple. Theres A Website That Does It For You. And It Has Yet To Give Me A Viruis And It Has Some Cool Features. The iBeer thing though is a v...

  • Can any one recomend a free web hosting company that dont give you a website builder that sopport full HTML.?

    If you are serious about websites either for personal or your business, don't go to free web hosting as they are usually not reliable and you may end up losing all your hard work. Free web hos...

  • Button (link)?

    If you host the button image on another site, use this code: <a href="URL_to_other_page" title="ToolTip Description"><img src="URL_to_image" style="wi...

  • What programs do I need to be a graphic designer? Do I just need the adobe creative suite? Or are there more?

    ...

  • Help in c++ program?

    You aren't very specific with your request. How will the numbers be input (e.g. entered at the console, constant array, from a file) into the program? Any particular number format (e.g. inte...

  • Decompile a EXE then recompile it in a seperate exe?

    Yes. But you will only get a version of the source. You would have to rewrite it yourself. In other words, the closest you could get is to see the shell. When the file was converted to machine lan...

  • Can i be come a web designer..or a animator..?

    You can be and do anything you want if you take the time to learn.

    ...
  •  

    Categories--Copyright/IP Policy--Contact Webmaster