The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

So, Let's get to the point. I need some hint for the algorithm for my project.
One monster will attack earth. It doesn't need army because the monster can duplicate itself.
The monster divided into 2 kinds, BLACK monster and WHITE monster.
BLACK MONSTER divided itself into BLACK monster and WHITE monster.
WHITE MONSTER divided itself into BLACK monster and 2 WHITE monster each day.

At the invasion day (Day-0) only the BLACK monster come.
I must make the program that count the amount BLACK monster, WHITE monster, and total both of them at n-day.

Create a Monster class with (at least) the attributes 'color' and 'number'. The attribute color doesn't actually have to be the type Color. It could be a String, a boolean, a number, or . . . You decide how you want to define black and white.

Create a collection or appropriate data structure (perhaps 2 or 3) to store Monster objects. A Queue or two might be useful, but I haven't thought it completely through.

Start with 1 black monster as specified, ask the user how many days the simulation should run, then follow the simulation's rules to create the monster objects for each day, reporting the results at the end of each day. Report the total monster objects created at the end of the simulation.

Sorry for the delay. The site was apparently down when I tried to get on yesterday.

What are you confused about? If you're unable, unsure, or just hesitant to create a program with more than one class, or you know nothing about data structures like queues, then you need to say so. If you are limited by policy to use only that which the instructor has taught you, then you need to let us know which Java tools you can use. Or if this is a personal project you've taken on just to learn and practice programming basics, let us know that.

The code you posted to get the user's input is a start, but what about the Monster class? What did you have in mind for the monster() method you've outlined? Comments in your code that describe the code's purpose would be helpful.

Yes, I don't understand queue yet. This is for my personal project. The reason I created monster() method is I tried to describe your explanation about creating Monster class, and I tried to write it down into subroutine. But, actually I've no idea about subroutine yet, I just tried it to realize your explanation.
But it seems wrong, hahaha.
I just understand java from if statement, looping, sorting, searching, arrays. So, can the program completed without queue but just with my understanding here? Can you give me hints?
Sorry my English isn't good.

A queue (or two) would be a convenient way to keep track of the Monster objects first as they are created, reported, and then as they are used to create the next generation of monsters. Since the monsters you've described have multiple characteristics that are important to produce the output you've shown, they would best be managed as objects.

I'm all for self study and pursuing your own projects, but it's important to study topics in the right order so that you obtain an appropriately broad and deep foundation of the basics. It's also important to be adequately prepared for the projects you take on so that you don't become discouraged and give up. It's not easy to know what you need before imagining and then starting a project. I believe you also asked for a site with projects to practice. All of this put together suggests to me that you need guidance in choosing what to study and what projects to take on. I suggest you restart your studies with a book to give you the guidance and practice you need in the right order and to build your confidence in and experience with the basic skills.

This project is from my book, the old one actually that my brother has years ago. It is said this is the project for the concepts of java around if statement until array.
Actually I can simply go on skip this project from the book, but its make me itchy to solve this. -_-
I keep trying then.

By "until array" do you mean using arrays? If so, they're pushing you to a solution using parallel arrays which is a painful step prior to creating a Monster class. I recommend avoiding the parallel arrays approach as an unnecessary pain suffered simply to reinforce that it's a bad design. Just as you can take a stranger's word that stabbing yourself in the eye with a sharp pencil is a bad idea, accept that using parallel arrays to store data is a bad approach.

Another issue with using arrays for this problem is that you don't know how large the arrays will need to be.

Yup, I will never using parallel arrays :p
My understanding is until searching. But, if I really stuck for this project, I'll skip it for now.
When I figure it out and make some codes, I'll post the thread in "What wrong with my code?"