darkagn 315 Veteran Poster Featured Poster

what core subjucts would i need to be good at to find this subject not to challenging i.e maths, science etc.

Certainly maths knowledge is an advantage (particularly algebra) and physics can be helpful (although I never studied physics after year 10 at school). There are actually a few philosophy subjects at university/college that can be advantageous too (Logical Thinking especially).

darkagn 315 Veteran Poster Featured Poster

so what have you done so far?

darkagn 315 Veteran Poster Featured Poster

Australia and proud of it! Happy New Year everyone!

darkagn 315 Veteran Poster Featured Poster

So your basic algorithm is:

if (number < 1) {
  // print out "enter more"
} else if (number <= 4) {
  // print one of the fortunes
} else {
  // print out "enter less"
}

You have the first and last section done, it's just a matter of working out how to choose a particular fortune. Do you want the number 1 to correspond to the first fortune, 2 to the second etc or do you want it to be random?

darkagn 315 Veteran Poster Featured Poster

start quote:

   if(number > 1){
       System.out.print("You will become rich.");
       System.out.print("You will meet your evil twin in 2 days.");
       System.out.print("Look out for the number 8. It means danger.");
       System.out.print("You will lose your memory after today!.");
    }

end quote.

This statement reads "for any number entered that is greater than one, do all of this in order." I don't believe that is what you are trying to achieve here.

Also if number = 1, then nothing will happen in your code.

And if the number is greater than 4, the above statement will execute as well as the code following it! You need an if-else statement rather than a series of if-statements.

darkagn 315 Veteran Poster Featured Poster

Hi Loreto,

What I think you are trying to do is have one JOptionPane print out all the numbers once but your code is printing each number one at a time in separate JOptionPanes. So what you need to do is create a String with the numbers you want to print in the loop you have, then outside your loop call the JOptionPane with the String rather than arr[y].

Hope this points you in the right direction :)

darkagn 315 Veteran Poster Featured Poster

Hey there kafil03,

Sorry but that's against the DaniWeb rules. We can only show you the door; it is up to you to step through it. That is, try doing some yourself and if you come across some specific problems, post in the appropriate forum and I'm sure someone will offer some good advice.

All the best,
darkagn.

darkagn 315 Veteran Poster Featured Poster

change from show() to setVisible(true) .... and find a better tutorial, that one's outdated.

Masijade's right here - find a tutorial on swing rather than awt as the swing packages have mostly overtaken the functionality of the awt packages.

darkagn 315 Veteran Poster Featured Poster

Hi markn50 and welcome to DaniWeb. I hope you find the answers you seek...

darkagn 315 Veteran Poster Featured Poster

Hi bramu and welcome to Daniweb.

What DVD Burner do you have? What blank DVD's are you using? What software are you using? What errors do you get when you try to burn?

darkagn 315 Veteran Poster Featured Poster

Why can't you use a loop to do this? It would be so much easier and it really shouldn't matter if you do.

If it is that important not to use a loop, do you know the size of the array before the user inputs the numbers?

darkagn 315 Veteran Poster Featured Poster

Actually the FlowLayout will wrap around after you "fill" your first row. But I think you might find it easier to use something else. Might I suggest a BorderLayout, with a BoxLayout in the BorderLayout's CENTER panel to house the username and password fields.

darkagn 315 Veteran Poster Featured Poster

Hi Sebouh,

I'm not 100% sure how to do what you want, but Java does have quite a few sql libraries in its API known as the JDBC. If you post your question in the Java forum, someone with more knowledge than I can claim might be able to help you further. :)

Cheers,
darkagn

darkagn 315 Veteran Poster Featured Poster

Take a look at the Java API in the Integer class, especially the parseInt and intValue methods. The Java API is located at http://java.sum.com/javase/6/docs/api - you should probably bookmark this page if you want to learn Java.

Sorry, there is a spelling mistake in that URL. It should be http://java.sun.com/javase/6/docs/api - sorry about that! :$

darkagn 315 Veteran Poster Featured Poster

I don't understand your comment...can you please just show it to me cause I am new in java so I am still unfamiliar of the things that you are saying...

Take a look at the Java API in the Integer class, especially the parseInt and intValue methods. The Java API is located at http://java.sum.com/javase/6/docs/api - you should probably bookmark this page if you want to learn Java.

I am having errors from:

out.println(average);  //it does not recognize average 
  StringTokenizer st=new StringTokenizer(number);  //it does not recognize StringTokenizer
  for (int i=0; i<number.length; i++){   //it does not recognize number.length

This is the error that shows...
root cause

java.lang.Error: Unresolved compilation problem:
average cannot be resolved

AverageNumber.doGet(AverageNumber.java:20)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

average has not been initialised before this line, so it doesn't make sense to print it out. The StringTokenizer error is caused because you need to import it by adding the following code at the very begining of your code:

import java.util.StringTokenizer;

number.length doesn't make sense because number is initialised as an int. I'm not sure what you are trying to do here, but either number needs to be an int array or the for statement should be < number as opposed to number.length.

darkagn 315 Veteran Poster Featured Poster

I think you might be better off listing your GUI components outside the methods. You still initialise your components inside the swingMenu method, but doing it this way gives global access within the class. For example,

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class SwingMenu implements ActionListener{
   JMenuBar menuBar;
   JMenu filemenu;
   // etc
   public static void main(String[] args) {
      SwingMenu s = new SwingMenu();
   }

   public SwingMenu(){
      menuBar = new JMenuBar();
      filemenu = new JMenu("File");
      // etc
   }
}

Then you can access the components within the actionPerformed method as needed.

Hope this helps.

darkagn 315 Veteran Poster Featured Poster

Instead of

System.out.println(st.nextToken());

you should assign the nextToken to a String then get the intValue from it using the Integer.parseInt method. Then you will be able to sum your numbers.
To get the average you will need to cast either the sum or the number to a double or float because the result of int / int is always an int. This will not always be accurate.

darkagn 315 Veteran Poster Featured Poster

The only problem I can see is that your division is an int / int which is always an int. For example, 10 / 4 is 2 (not 2.5). In order to fix that you will need to cast the result to a double or float by doing the following:

System.out.println("The average of all the values in the Array List is " + (double) avgTemp/count1);

Hope I've helped, please let me know if there are still problems.

darkagn 315 Veteran Poster Featured Poster

Hi neow and welcome to Daniweb,

I'm not sure what you meant by the statement:

my problem is how can i compute the operands that i inserted.

Do you mean how do you get the operands from the user input? Or are you asking how to compute the entire equation once the user has inputted the operands and operators?

darkagn 315 Veteran Poster Featured Poster

When the user inputs the numbers, you will have a String. Take a look at the API for the StringTokenizer class - I think you will see that this will be a useful class to separate the numbers (called tokens) by the commas (separators).

Hope this has given a hint in the right direction,
darkagn

darkagn 315 Veteran Poster Featured Poster

Hi there gpsmike and welcome to Daniweb,

Your question sounds like a javascript question as opposed to pure Java and there is another forum for JS under Web Development. Try posting there and maybe someone with more knowledge of JS might be able to help you.

Good luck :)
darkagn

darkagn 315 Veteran Poster Featured Poster

Hi there primbech and welcome to Daniweb,

What specific difficulties are you having with your pst editor? Maybe post some of your code and we will try to help. :)

darkagn 315 Veteran Poster Featured Poster
for (int s:a)

is shorthand for

for (int s=0; s<a; s++)

in Java. I'm not sure if you can use printf statements like the ones you have there though - that's a C++ thing.

darkagn 315 Veteran Poster Featured Poster

Also use i>=0 rather than i=>0 in your for loop.

darkagn 315 Veteran Poster Featured Poster

dReg1 in the above code is an Accumulator, a register that is used to keep track of the result of the calculations. If you think about how a calculator works, you enter a number, press the operator, enter a second number (dReg2) then press equals to find the result. Then you can (if you want) press another operator and yet another number and find another result. And so on. This result is stored in a special register (called the Accumulator). The line

dReg1 = Calculation(sOperator, dReg1, dReg2);

is exactly how an accumulator works. It is possible to create a third register to store the result, but not only would this use more memory but it is not how an Accumulator works, accumulating the result in a single register.

As for your second question, those three lines of code simply print the result to the screen. If you mean what do each line do, then the first converts the result dReg1 to a Double object (as opposed to a double variable type), the second line converts it to a String, and the third sets the text of the display to that String.

Hope this has helped,
darkagn

Jishnu commented: Nice +2
darkagn 315 Veteran Poster Featured Poster

I think this error occurs when you haven't properly defined your class and often it is that the class name and file name are different. Please post your code (using code tags) so we can give you a more specific solution.

darkagn 315 Veteran Poster Featured Poster

What don't you understand about Exceptions and Threads? They are two pretty broad topics so please try to be more specific and we will try to help :)

darkagn 315 Veteran Poster Featured Poster

Hey there satya5321,

You have answered a couple of threads in the Java forum today that have already been fairly well finished and are over three weeks old. Please check the date of the last post before replying to a thread.

Cheers,
darkagn

darkagn 315 Veteran Poster Featured Poster
for (i = intArray.length-1; i>=0 ; i--) { // sort at end of list

            for (j = 0 ; j < i ;j++) { // "bubble" the largest value to the end

                if (intArray[j] > intArray[j+1]) { // compare each element to the next one

                    temp = intArray[j]; // swap the elements by first setting a temp variable

                    intArray[j] = intArray[j+1]; // then copying one to the other

                    intArray[j+1] = temp; // and recopying the temp
               }
        }
                   // print out the results
                   System.out.println(" Array content after sorting");

                   for(i=0 ; i < intArray.length;i++) { // for each element

                             System.out.print(intArray[i] +""); // print it!

                 }
       }
darkagn 315 Veteran Poster Featured Poster

I'm a bit skeptical that a trainer would assign a newbie to java such a large scale project with four days to complete it (in J2EE no less!)

darkagn 315 Veteran Poster Featured Poster

The Math.abs function returns the absolute value of the number passed in as a parameter. Check out the java API for more information.

darkagn 315 Veteran Poster Featured Poster

-- Arnold Schwarzenegger

"I'll be back"

"He had to split"

"I had to let him go"

"Hasta la vista, baby"

"Let off some steam, Bennet"

"It's not a tumor"

"I like you so I'll kill you last"

"Consider this a divorce"

"I eat green berets for breakfast... and right now I am very hungry"

"You have no respect for logic. And I have no respect for people with no respect for logic"

:)

darkagn 315 Veteran Poster Featured Poster

I haven't used a mac for quite some time so I could be wrong, but don't most macs come with g++ these days? You can use it from your Console utility and should be a sufficient compiler for a starter programmer.

darkagn 315 Veteran Poster Featured Poster

One advantage of lists that I can think of is that it is often easier to rearrange the data in a list because you are working with pointers. That is, if you have a list of objects and you want to change the order of the data, you can simply change where each pointer points to, rather than having to copy the array to a new array in the specific order that you want. Thus, sorted lists are easier to implement than sorted arrays.

darkagn 315 Veteran Poster Featured Poster

It might pay to repost this question in the "Shell Scripting" forum if you want to specifically use a batch script to do this. Someone there may be able to help.

Good luck,
darkagn

darkagn 315 Veteran Poster Featured Poster

Hi and wecome fellow Aussie! (We are slowly taking over Daniweb) <insert evil laughter> :D

jbennet commented: rep time +22
darkagn 315 Veteran Poster Featured Poster

Looks like darkagn and I replied at about the same time. I hadn't refreshed my page while typing my reply.

I think you explained it much better than I did though :)

darkagn 315 Veteran Poster Featured Poster

It looks to me like it is a flag to tell whether something has been inputted or not. If it hasn't, isFixReg is set to true, and pressing a number (for example) starts a new String. Otherwise, isFixReg is false and entering a number will add to the existing text.

It might pay to check this with T.Yamazaki via the email address that is provided, but since the code was written over 11 years ago you may not get a response from that address.

As an aside, this is why it is important to provide meaningful names and/or comments for methods, variables, classes etc. Just because the author of the code knows what it means doesn't mean that they will always be responsible for maintenance of the code.

Jishnu commented: Nice post :) +2
darkagn 315 Veteran Poster Featured Poster

Just to be clear, the "Java" = J2SE right?

darkagn 315 Veteran Poster Featured Poster

Hi namitiet07 and welcome to daniweb,

Did you have a question regarding this thread?

darkagn 315 Veteran Poster Featured Poster

I think masijade was talking about the method

Integer.parseInt(String s, int radix)

Check out the API for this static method which parses a String s to an Integer value in the base radix.

darkagn 315 Veteran Poster Featured Poster

I agree with jbennet but would like to add that perhaps your best bet would be to contact the GIMP community administrators and just double check with them. They may have specific requirements that you need to adhere to.

darkagn 315 Veteran Poster Featured Poster

Welcome scholly! It is always good to welcome a fellow aussie to this forum :)

darkagn 315 Veteran Poster Featured Poster

Maybe you could create a fairly simple Score class that records the player's name and score, and use an ArrayList of Score objects to record the order of high scores. Then to display them, possibly use a JDialog or JOptionPane? Check out sun's tutorial on using dialogs for more info on how to implement this.

Good luck,
darkagn :)

darkagn 315 Veteran Poster Featured Poster

No problem :)

darkagn 315 Veteran Poster Featured Poster

Actually it wasn't that I didn't understand the question, I just wanted cbalu to think about it before I suggested a reason why interfaces can't have static methods. It was my way of getting cbalu to put in some effort to the question.

darkagn 315 Veteran Poster Featured Poster

Hi Richard and welcome!

I travelled to Costa Rica this time last year with my wife and fell in love with the country. We were in San Jose for Christmas and saw the Tope festival. I loved Manuel Antonio, Samara, Monteverde, Isla Tortuga... I could go on for hours :)

darkagn 315 Veteran Poster Featured Poster

What's the difference between turn based and rpg?
And FIFA Soccer as the most influential sports game??? Just curious as to how you came to that conclusion.
First Person Shooter: Doom / Quake
Real Time Strategy: Legend of Zelda
Turn-based Strategy: Risk (hehehe, beats me)
Role Playing: Final Fantasy 7
Racing: the original Test Drive (on 5.5 inch floppies) / the original Need for Speed
Action / Adventure / Puzzle: Myst
Sport: Madden
Platform: Sega Genesis
Fighting: Punch Out / Pit Fighter
Horror: Resident Evil
Crime: Grand Theft Auto

Yeah I had to stretch a bit for a sport game because I'm not really a fan of the genre.

Turn-based strategy and RPG's are very different genres of games - in turn-based strategy the object is usually "world domination" or similar and you have your turn of moves and sit and wait for your opponents to make their moves. An RPG sees each player wandering around, talking to NPC's and other players, fighting, solving puzzles etc.

I would classify Legend of Zelda as a RPG rather than a RTS. RTS's are where players race to defeat their opponents in a "world domination" scenario or similar but everyone makes their moves at the same time.

darkagn 315 Veteran Poster Featured Poster

could be because the issue is influence and not popularity. that is why i said warcraft and not age of empires. we are looking for games which had a profound and lasting effect on the gaming industry. at least i think. :-)

Yes that is what I was wanting to discuss, RW.

An RTS that was rather different to most was Battle Realms where you could only advance past a certain 'level' of soldier by skirmishing, rather than relying on being solely the fastest resource gatherer. The system never really caught on in the genre however, so I didn't include it in my original list.

darkagn 315 Veteran Poster Featured Poster

Hi cbalu,

Do you know what a the difference between a static and non-static method is? Do you know what an interface is? Let me know your thoughts and I will try to help from there. :)