Jocamps 14 Junior Poster

firstly you have two same constructors at line 83 to 90. And your error was caused by a lack of a semicolon on the Person class. line 111 is not the end of Person class rather its the end of equals() method. you need to add one more semicolon after that.

Jocamps 14 Junior Poster

1. client class/interface does not exist
2. client class/interface does exist BUT with an uppercase "C"

Jocamps 14 Junior Poster

can you post your new code?

Jocamps 14 Junior Poster

There are a lot of options you can choose from:

Connections:
1. using an ethernet cable
2. using RS-232
3. USB ?

I suggest using an ethernet cable. its very easy to set-up a network and write a communications program in java (ie., using sockets, other network protocols etc). In using an RS-232, you need to know about COM ports and the specifics of the protocols, take a look on here:

http://www.java2s.com/Code/Java/Development-Class/OpenaserialportusingJavaCommunications.htm

Jocamps 14 Junior Poster

Take a look at the documentation for the String class in the API

http://java.sun.com/j2se/1.5.0/docs/api/

Jocamps 14 Junior Poster

here's a tutorial and an example

http://www.java-samples.com/showtutorial.php?tutorialid=392

Anyways, just to let you know what you did wrong in your code:
1. when you write the int values, by using the write() method you actually was writing the byte values of the ints... you will have trouble once your int values go over 255 (try it). On this note, since you used data streams you could have used writeInt()
2. Same as writing the comma. you could have used writeChar(',') or writeChars(","). read the API for more information on this
3. Now when you read your data file, you were reading the bytes by using read() therefore what is stored in your arraylist are the byte values hence you get 44 for the comma.
4. those problems above was carried over in your printInputList() method

Jocamps 14 Junior Poster

Indeed there must be the problem in using System.out.println instead of System.out.print in the inner loop.

WHAT??

Jocamps 14 Junior Poster

Object is the superclass of all objects in JAVA which includes your Person class. Person therefore inherits attributes and methods from Object.

you can override the method equals(Object obj) of the Object class in your Person class by having equals(Person inPerson) because Person is also type of Object.

confused much? :)

welcome to the object-oriented programming! yay!

Jocamps 14 Junior Poster

try this in yout printInputList() method :

for (int i=0; i < inputList.size(); i++) {
        	   if(inputList.get(i).equals(new Integer(44)))
                   dataOutput += ",";
        	   else
        		   dataOutput += inputList.get(i);
               }
           }

the would simply compare the input values to 44 (which is the character encoding for the comma) and append a comma to the output if found. otherwise it appends the int value.

by the way, why not use a FileReader or FileWriter instead?

Jocamps 14 Junior Poster

start by reading the tutorials in the sun java website. there are simple examples that you can look into as well on that website. google is your friend!

Jocamps 14 Junior Poster

set your stack as a global variable. In your code, what happens is, everytime you click a button you created a new Stack object it would work with push() since you have the initial value to be push but when click the pop button, a new Stack object is created which is empty (even if you click push() first).

also you could include an if statement to check if the stack is empty before using pop() method.

just noticed you were using a JTextField , so your stack.push(pushstring) should be :

stack.push(pushstring.getText());
laidback7 commented: exceptional +0
Jocamps 14 Junior Poster

No you haven't posted the code right. The last code tag should have a forward slash like this: (/CODE)

For your problem, In your ActionListener you are passing a Stack object to the JLabel setText() method when it was expecting a String.

Instead of using this:

resultLabel.setText(stack);

YOu should have this:

resultLabel.setText(stack.toString());

and don't forget to remove the extra space in between "pop" and parenthesis:

else{
stack.pop ();
resultLabel.setText(stack);
}
Jocamps 14 Junior Poster

you will not learn until you try it yourself. read some tutorials about threads and applets then start coding your own. If you get stuck at some point or if you need some clarifications then thats when you ask people here at the forum.

Jocamps 14 Junior Poster

Not entirely sure what you meant by "data source" but you need to save your excel file where you know what the data structure, I normally save it as a CSV (comma delimited) coz its easier to read this way and extract my data.
Example you have a table that looks like this in excel:
Age Name year of Birth
20 someone 1985
18 someone1 1988
....(and so on)

If you save this to a CSV file (File > Save as > Save as Type > CSV)
the data in your *.csv file would look like this:

Age,Name,year of Birth
20,someone,1985
18,someone1,1988

Jocamps 14 Junior Poster

Keep in mind that each node in a LinkedList contains a "NEXT" pointer, which points to the next node and/or a "previous" pointer which points to the previous node. You may set-up a Node class which contains the element of that node and the pointers:

public class Node{
    Node next;
    Node prev; //this is optional 
    Object element; //this could be any types 
}
Jocamps 14 Junior Poster

use the normal FileWriter class. read the java api for more information on how to do this .
http://java.sun.com/javase/6/docs/api/

Jocamps 14 Junior Poster

read the java api , specifically on the String class and String operations. all the answers are in there. Also take a read on the tutorials in Sun Java website regarding Strings
http://java.sun.com/docs/books/tutorial/java/data/manipstrings.html

Jocamps 14 Junior Poster

yes there is! firstly, you need to know how the data is stored in the file (ie., structure, data types etc). Then you can read the file through a java program and do your data analysis.

Jocamps 14 Junior Poster

if you learn by examples, there are a lot of useful JAVA snippets here in Daniweb. you can also find tutorials and resources on the sticky thread in theh JAVA forum.

http://www.daniweb.com/forums/thread99132.html

Jocamps 14 Junior Poster

Your why's, what's and how's on ImageIcons are answered here:
http://java.sun.com/docs/books/tutorial/uiswing/components/icon.html

Take a closer read on "Loading Images and Using getResource" (it's somewhere in the middle of that page above) :)

Jocamps 14 Junior Poster

for clearing the checkboxes simply use:

//Topping choices
jchkCheese.setSelected(false);
jchkPepperoni.setSelected(false);
jchkSausage.setSelected(false);
//do this for your other checkboxes

do this for all the checkboxes.
For your radio buttons, you are on the right track by grouping them however you need to make this as a global variable so that you can use it for the clearing method then use that group to clear your selection.

drinkSize.clearSelection();
//do this for your other button groups
Jocamps 14 Junior Poster

one way you can do it is to have methods which determines min, max and ave. and everytime the user inputs a number it calls this methods.
1. for the min/max if its the first run obviously any number from the user is the starting value. then for succeeding inputs, compare if that is less/greater than mini and max respectively.

2. for the average get the cumulative sum of the user inputs and devide this by the number of responses so far.

Note: if you are only concern with the min, max and ave values of the response, avoid storing the responses to an array of values. This is very inefficient in terms of execution and takes a lot of memory if the responses are significantly high.

Jocamps 14 Junior Poster

1. you did not include an actiontionListener() to your Calculate button. You should have:

jbtCalculate.addActionListener(this);

2. same as above you need to add an actionListener to the "clear" button. then you could make a method which clears all the selection and reset the total cost by using setSelected(false) methods of each components you used(ie radio buttons, checkboxes).

hope that helps :)

Jocamps 14 Junior Poster

i do this : " download my code from this :
http://www.4shared.com/file/140858938/8cf47f25/_2__MovePawn.html

I try but i can't .
please illustrate your answer with code

thanks

show us what you tried and we'll work from there. follow what peter_budo have suggested.

Jocamps 14 Junior Poster

if you are limited to using the premitive type of int as an array then you can do it this way:

1. loop through the array
2. if 0 is found then "shuffle" the preceeding elements by replacing the "0" element with the next element (if not zero).
3. count how many zeros were remove and create a new array of ints with size = orignal int array size - number of zeros remove
4. copy all elements from index = 0 to index = size-1, to the newly created array.

This is rather a very inefficient way to do it with arrays. I suggest you use an ArrayList or other data structures which have methods to remove elements.

Jocamps 14 Junior Poster

try setting your button to a certain width and scale the imageIcons by using getScaledInstance() method of the Image class.

Jocamps 14 Junior Poster

The question is..do you know how to program in JAVA? (you haven't mention it in your "skill levels")

Jocamps 14 Junior Poster

Actually the problem is you generated a new random number every time the user inputs a guess since the statement that this was inside the do-while loop. Try putting it outside the loop.

n= (int)(Math.random()*100.0)+1; //Math equation to generate random number
 do{
...
}			
 while ( number != n );
Jocamps 14 Junior Poster

You can just copy everything you had inside the main method (in the first code) and paste it to your getNumber() method without any parameters as what Grn Xtrm suggested. Since you declare the method as static, you can call it in the new main method as Guess.getNumber()

your second main method should look like this:

public static void main (String [] args)
	{
		Guess.getNumber();

	}
Grn Xtrm commented: Good team effort. Great working with you :) +1
Jocamps 14 Junior Poster

it's called regular expressions (java.util.regex)
take a look in here:

http://java.sun.com/docs/books/tutorial/essential/regex/

Jocamps 14 Junior Poster

er, how do i do that?

"CODE" put your code here "/CODE"

use that syntax above and replace the quotation marks with square brackets [ ].

Jocamps 14 Junior Poster


b) if you really want average to be rounded to an int, type cast the right side of the equals. "int average = (int) sum/TOTAL_NUMBERS;"

so what you should really have looks like this:

for(int i = 0; i < numbers.length; i++) {
sum += numbers[i];
}
float average = sum / TOTAL_NUMBERS;

Casting is not a good idea for rounding numbers to int. If you use the code above (casting), it will not round your average to the nearest int but rather it will truncate the resulting number and drop the decimal places. A better and accurate way to do it is to use Math.round(float average) which will actually round your average to the nearest int.
Example:
let's say average = 5.9
by casting to int:
average = 5
by using Math.round:
average = 6

your code should be like this:

for(int i = 0; i < numbers.length; i++) {
sum += numbers[i];
}
float average = Math.round(sum / TOTAL_NUMBERS);
Jocamps 14 Junior Poster

please enclose you code inside the CODE tags so its easier to read.

Jocamps 14 Junior Poster

I suggest you use a good JAVA editor and/or an IDE (Integrated Development Environment)...Eclipse, NetBeans or BlueJ to name a few. These errors are easily recognized by these editors and they can give you possible solutions to your errors too. It can even remind you of some JAVA conventions as what BestJewSinceJC has pointed out. If you are really serious in your programming, I strongly suggest using an IDE.

Jocamps 14 Junior Poster

ok then whats wrong with my while statement

Do not put a semi-colon at the end of your while statement.

Jocamps 14 Junior Poster

and show some effort at least

Jocamps 14 Junior Poster

you can start by reading java books or online java tutorials on how to make a program

Jocamps 14 Junior Poster

Write a class called Person.java that has instance variables matric number, name, date of birth, and gender. Use appropriate data types for these instance variables. Include constructor and set and get methods for all instance variables. Draw UML diagram for class Person.

Then, create an application class that asks the user to supply the required information for a Person object and then instantiates a Person object.

at least make some effort!

Jocamps 14 Junior Poster

first convert the string to char array and display the elements of that array backwards. There is a method in the String class which converts that string into char array.

Jocamps 14 Junior Poster

i couldnt start the server...i tried using commands in dos like.."tomcat start".The url i used was http://localhost:8080/

An easier way to start and stop tomcat is using the Tomcat Monitor. I think during the installation of tomcat it asks you if you would like to install that monitor . However if you did not choosed to install that.. you can go to the bin folder of your tomcat installation and start tomcat6w.exe It sits on your system tray and you can open it anytime to start and stop tomcat with a GUI.

Jocamps 14 Junior Poster

Try Robocode! It's a fun way to practice your programming skills (in JAVA) it's addicting and you can even join competitions to battle against the robots develop by other users.

http://robocode.sourceforge.net

I have been implementing a learning algorithm with my robots :)

Jocamps 14 Junior Poster

I'd say Master of Information Science.

Library = boring
Information = interesting

i'm really being subjective here ;)

Jocamps 14 Junior Poster

when you created your Circle class you had your "circle" in lowercase it should be in Uppercase.

Circle base = new Circle(r);

Jocamps 14 Junior Poster

Actually, when I opened your link there was an error message displayed in the java console. If you are using Mozilla you can go to Tools > Java Console. If you are using Internet Explorer , right click on the applet area and select Java Console.

The error was a 'java.lang.NoClassDefFoundError' which is caused when your browser couldn't locate the *.class file of your applet. There are two options you can go about solving this:
1. make sure all your *.class files are in the same directory as to your html file; or
2. use CODEBASE attribute of the APPLET tag in your html file(point the codebase to the directory of where your *.class files of the applet are located)

About the security thing read it here:

http://java.sun.com/developer/onlineTraining/Programming/JDCBook/signed.html

hope that helps :)

Jocamps 14 Junior Poster

Actually the problem was indeed the || instead of &&;
Thanks a lot everyone

told 'ya ;)

Jocamps 14 Junior Poster

Private and Public should be changed to private and public. They are supposed to be lowercase - I think it will give you a compiler error otherwise.

that's what i said...and yes it will definitely give you a compiler error

Jocamps 14 Junior Poster

Firstly, the start of the CODE block in posting your code here should be without '/' to display the formatted code correctly.

The way you set-up your Printwriter is without automatic flushing. You need to use flush() method after you write something into the file. Have a look on the documentation on how to set up automatic flushing.

are you just writing to the file once?

outFile.println(heatIndex[indexCounter]);
outFile.flush();
Jocamps 14 Junior Poster

Firstly, the start of the CODE block in posting your code here should be without '/' to display the formatted code correctly.

The way you set-up your Printwriter is without automatic flushing. You need to use flush() method after you write something into the file. Have a look on the documentation on how to set up automatic flushing.

are you just writing to the file once?

Jocamps 14 Junior Poster

Thanks. One more question:
Should I create ODBC entry for the data base this way:
Open the Administrative Tools icon in your Control Panel.
Double-click on the Data Sources (ODBC) icon inside.
Choose the System DSN tab.
Click on Add in the System DSN tab.
Select the Microsoft Access Driver. Click Finish.
In the next screen, click Select to locate the database.
Give the database a Data Source Name (DSN).
Click OK.
I'm new in data bases so any help will work.
Thanks

Did it work for you?

Jocamps 14 Junior Poster

It should be AND (&&) statements right instead of OR?