BallClock Java

“Tempus est mensura motus rerum mobilium” (Time is the measure of movement) - Auctoritates Aristotelis

…. and movement has long been used to measure time. For example, the ball clock is a simple device which keeps track of the passing minutes by moving ball-bearings. Each minute, a rotating arm removes a ball-bearing from the queue at the bottom, raises it to the top fo the clock and deposits it on a track leading to indicators to displaying minutes, five-minutes, and hours. These indicators display the time between 1:00 and 12:59, but without AM or PM indicators. Thus 2 balls in the minute indicator, 6 balls in the five-minute indicator, and 5 balls in the hour indicator means the time 5:32.

Unfortunately, most commercially available ball clocks do not incorporate a date indicator, although this would be simple to do with the addition of further carry and indicator racks. However, all is not lost! As the balls migrate through the mechanism of the clock, they change their relative ordering in a predictable way. Careful study of these orderings will therefore yield the time elapsed since the clock had some specific ordering. The length of time which can be measured is limited because the orderings of the balls eventually begin to repeat. Your program must compute the time before repetition, which varies according to the total number of balls present.

Operation of the Ball Clock:

Every minute, the least recently used ball is removed from the queue of balls at the bottom of the clock, elevated, then deposited on the minute indicator track, which is able to hold four balls. When a fifth ball rolls onto the minute indicator track, its weight causes the track to tilt. The four balls already on the track run back down to join the queue of balls waiting at the bottom in reverse order of their original addition to the minutes track. The fifth ball, which caused the tilt, rolls on down to the five-minute indicator track. This track hold eleven balls. The twelfth ball carried over from the minutes causes the five-minute track to tilt, returning the eleven balls to the queue, again in reverse order of their addition The twelfth ball rolls down to the hour indicator. The hour indicator also holds eleven balls, but has one extra fixed ball which is always present so that counting the balls in the hour indicator will yield an hour in the range one to twelve. The twelfth ball carried over from the five-minute indicator causes the hour indicator to tilt, return the eleven free balls to the queue, in reverse order, before the twelfth ball itself also returns to the queue.


The input defines a success of ball clocks. Each clock operates as described above. The clocks differ only in the number of balls present in the queue at one o’clock when all the clocks start. This number is given for each clock, one per line, and does not include the fixed ball on the hours indicator. Valid numbers are in the range 27 to 127. A zero signifies the end of input.


For each clock described in the input, your program should report the number of balls given in the input and the number of days (24-hour periods) which elapse before the clock returns to its initial ordering.

Sample input: (note - Moodle inserts spaces between lines every time i type a return, because it is TERRIBLE. There should be NO EMPTY SPACE LINES in your input, or output)




Output for the sample input:

30 balls cycle after 15 days.

45 balls cycle after 378 days.

How to deal with input:

You will save your input file as text, then send that into your program using the command line redirect operator as follows:

java Homework2 < [login to view URL]

Your program will treat the input as though it is coming from the keyboard, i.e. build a Scanner, attach it to [login to view URL] and grab the nextInt() until you get a zero, signaling the end of input.

Compétences : Java, Algorithme, Programmation C, Architecture Logicielle, Programmation C++

en voir plus : java web start audio recorder, start free sms website, java web start generate barcode, java creator 200 free tutorials, start free phpnuke website, java photo gallery free, java web start netbeans, java drag drop free, start free hyip website, java digital signage free player, java programming malik free ebook, java helpdesk ticket free, java radio stream free, free time input control code, java web start dicom viewer, adult networks start free, simple java project start, applet java upload folder free, java web start free download

Concernant l'employeur :
( 0 commentaires ) Metairie, United States

Nº du projet : #20105435

Décerné à:


hi I am really interested in your project I have full experience of java programming I could make your java program for ballclock as you want I could satisfy you Everything will be done well if you work with me Thank y Plus

%selectedBids___i_sum_sub_4% %project_currencyDetails_sign_sub_5% USD en 1 jour
(52 Commentaires)

7 freelance font une offre moyenne de $165 pour ce travail


Hello? Nice to meet you. I am excited to work with you on this project. I am ready to start work immediately. I have good skills in those. So I think I can help you if you want. Thank you. Best Regards.

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 3 jours
(95 Commentaires)

Hello. I have read your description and I am so interested in your project. I am confident in your project and I can finish it clearly on time. I am well experienced and skillful Java and OOP programmer. I have +15 ye Plus

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 2 jours
(128 Commentaires)

hello,how are you.i read your bid carefully. i am java/javafx expert and have full experience for 12 years. java/javafx is my top skill and passision. i can provide most quality and high speed. if you want to success, Plus

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 7 jours
(11 Commentaires)

Hello. I am very pleasure the opportunity to discuss this job with you. I am a full time freelancer with skills and experience on java,JavaFx,intellij,Netbeans, Mobile phone and android studio etc. Especially, I have Plus

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 7 jours
(15 Commentaires)

Dear sir I have already studied your task in detail. I have a lot of experiences in this field. I'm an expert in c/c++, java algorithm and its data structure. If you ping me, you'll get a good result for a few hours. T Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(3 Commentaires)

Dear sir. How are you? I have gone through the requirement and would like to raise my interest in the same. I am an expert at : Java, C/C++. I believe I have most of the skills that you are seeking and would like to be Plus

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 5 jours
(1 Évaluation)