javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Where do you get the errors? (at which lines)
Post part of the code where you get the error, with the error message

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Use the BufferedReader class with stultuske's code. This class contains the readLine() method you need

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Follow the link I gave you for html and peter_budo's link for JDBC.

I would suggest first to get familiar with JDBC and design your database. (download mySQL server and some tutorials about creating tables and schemas. perhaps peter_budo's link will help)

And after you are done with html try to learn JPS. If you get familiar with the terms: "request" and "response" you will have no problem

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

When will you ever say yes, or turn off your email blocking???

When will the madness stop???

=P

Madness?

This is SPARTA.


PS: And I am from Greece

peter_budo commented: You don't mess with the Zohan +10
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Does the whole program work now?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

JSPs have nothing to do swing. (That was my first mistake). Meaning that you cannot modify your code to convert swing to JSP.
The only thing you can keep the same are the classes. Everything that is GUI related has to go. Which is why we don't implement too much code in the class that displays the GUI and we use methods from other classes.
If you have already done this in swing I hope that you have kept the reading and writing to the database in separate classes so you can reuse them.

Start by learning HTML, in order to create the GUI:
http://w3schools.com/

Then download an IDE like: Netbeans

As for mySql, you can look for tutorials at the internet or examples in this forum

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

this is probably a bad question but this:

public ClassRecord getClassID(int index)
	{
	return ClassID[index];
	}

is giving me a cant find symbol ClassID error, is that what its supposed to look like

At the above the error is this:
return ClassID[index]; and
public ClassRecord getClassID(int index)

You got close with this:

public ClassID getClassID(int index)
	{
	return new ClassID();
	}

Use this:

public ClassID getClassID(int index)
	{
	return ............[index]; //add what is missing at the dots. What do you need to return from the class ClassRecord? What the for-loop in which this is used does?
	}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
pw.println(theList.toString());;

You call the toString() of class ClassRecord, not ClassID.
I see that you have a for-loop but you call the same thing:

for (int i = 0; i < count; i++)
{
pw.println(theList.toString());
}

You should be getting in each loop the ClassID item and writing the toString() of that:

Add a getClassID(int index) method in ClassRecord
Add a getCount() method in ClassRecord : will return the count variable

And have count being the size of the array

count = theList.getCount();
for (int i = 0; i < count; i++)
{
ClassID clId = theList.getClassID(i);
pw.println(clId.toString());
}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
public class TestClass {
    public static int count=0;
    
    /** Creates a new instance of TestClass */
    public TestClass() {
    }
    
    public static void main(String [] args) {
        TestClass tc1=new TestClass();
        tc1.count=5;
        
        TestClass tc2=new TestClass();
        System.out.println(tc2.count); //will print 5 NOT 0
        
        TestClass.count=10;
        
        System.out.println(tc1.count); //will print 10
    }
}

Note that since count is static all instances manipulate the same variable.

Now in a non-static method you can use static methods and variables.

But in static methods, you cannot use non-static methods and variables. Because non-static methods and variables need to be called by an instance of the object and the static method in which they are can be called without an instance of the class.
Of course in order to bypass that you can create a new Object in the static method, depending if this is what you really want.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

In the class: ClassRecord have you implemented (overridden) the method toString() ? If not then when you call this:

pw.println(theList.toString());;

since you have no toString() method you call the toString() method of the super class.
Yes, ClassRecord has a super class, the Object class. In final what you call is the toString() method of the Object class.
Better write in the ClassRecord a toString() method returning what you want to write in the file

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

These methods and variables don't need an instance of the object to be used:
If in an object: MyObject there is the static variable: VAR and the static method method1(), then instead of:

MyObject my=new MyObject();
String s = my.VAR;
my.method1();

you can also do this:

String s = MyObject.VAR;
MyObject.method1();

One other thing with static variables is that in memory they are common for all instances of the object. When you create different instances of the same object the variables of the object are different and they take their own space in memory, but with static no matter how many instances you create the variable will be ONE.
Also if you create an instance and you change the value of a static variable with it,
and then you create a new instance the static value of the new instance will be the same as the one previously changed. All the different instances have access to ONE variable and they all change the same variable.

Soon an example about the last one

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Thanks ..i thought JSP is a server side scripting language using in web development..Am i right..? My question is which will be more efficient and useful for this project...

Actually .jsp files have html "code" inside them (the proper term is html tags). But with JSPs you can add java code inside them. For example calling a method to get in an array data from DB and displaying them:

<html>
<head></head>
<body>
<%
String [] array = getData();
%>

<%
for (int i=0;i<array.length;i++) {
%>

<!--HTML CODE HERE-->
<h4> <%= array[i]%> </h4>
<br>

<%
}
%>
</body>
</html>

This is a poor example but the general idea is that if you want to develop a web application with java you will write jsp and you will need to learn HTML as well.
Write the code and create classes with java. Don't put "business" in jsp.
For example don't create connection to read from a database in a jsp.
Create classes that do what you want and then create the GUI (jsp/ html) and call those classes in the jsp in order just to display the results

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

From a tutorial I have:

For example, to create a cookie named userID with a value a1234, you would use the following.

Cookie c = new Cookie("userID", "a1234");


If you create a cookie and send it to the browser, by default it is a session-level cookie: a cookie that is stored in the browser's memory and deleted when the user quits the browser. If you want the browser to store the cookie on disk, use setMaxAge with a time in seconds, as below.

c.setMaxAge(60*60*24*7); // One week


To send the cookie, insert it into a Set-Cookie HTTP response header by means of the addCookie method of HttpServletResponse

Cookie userCookie = new Cookie("user", "uid1234");
userCookie.setMaxAge(60*60*24*365); // Store cookie for 1 year
response.addCookie(userCookie);

To send a cookie to the client, you create a Cookie, set its maximum age (usually), then use addCookie to send a Set-Cookie HTTP response header. To read the cookies that come back from the client, you should perform the following two tasks, which are summarized below and then described in more detail in the following subsections.

Call request.getCookies. This yields an array of Cookie objects.

Loop down the array, calling getName on each one until you find the cookie of interest. You then typically call getValue and use the value in some application-specific way.

String cookieName = "userID";
Cookie[] cookies = request.getCookies();
if (cookies != null) {
  for(int i=0; i<cookies.length; i++) {
    Cookie cookie = …
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You forgot the parenthesis at the end:
total=first.getPages()+ second.getPages()+ third.getPages;
total=first.getPages()+ second.getPages()+ third.getPages();

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

As you say in one of you other posts, if you are new and don't know how to make code,
start by writing simpler codes

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

hello,,can you help me with my problem??if it's okey for you,,,

right now,,we are required to make a calculator using only string..ex:

i can only use JOptionPane/BufferedReader

Input
Mathematical String: 2 + (3*2)

Output
Result: 8

how can i implement the codes??do you know any other sites that could really help me about this problem??thank you again...

Start your own thread, Don't hijack or post in different threads the same question. And show us some of your code and where are you having trouble

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Probably because the file does not exist.
And you could use BufferedReader for reading from file.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Create in a separate class methods for connecting writing and reading to the database.
Then replace the code where you write to the file with the methods from the class

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

am getting the error ") expected" at line 68..Is there a way I can call the method printInfo from the class mainPrg? maybe something like calling the class Chapter from mainPrg which can call the method printInfo..

Don't tell me that you couldn't also figure out that out?

Create an instance of the class whose method you want to call.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

And the getPages(), getTitle(), methods are not declared in the Book class. That is why you get error. They are defined in the Chapter class so you should do:

public void printContents()
	{
		System.out.println("Contents:");
		System.out.println("1." +first.getTitle()"........." +first.getPages());
		System.out.println("");
		System.out.println("2." +second.getTitle()"...........:" +second.getPages()"\n");
		System.out.println("");		
		System.out.println("3."+third.getTitle()"...........:" +third.getPages()"\n");
		System.out.println("");
	}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You will instantiate a class the extends from InputStream. The class will have implementation of the abstract methods.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Please post the errors you get and at which line you get them

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
for (int i=0;i<personList.size();i++) {
  String s = personList.get(i);
}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The Person class is abstract. So the classes that extend Person must implement all the abstract methods of Person.

The classes: Students and Lecturers must implement the method getRegisterNo() .
You have forgotten to implement this method when you did:

Students extends Person

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I am sure that someone, someday will understand what you are trying to tell us

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

It looks OK. What is your problem?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
double a = Math.exp(b); //e^b

double c = Math.pow(a,b); //a^b

Go to this link: Math

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I trust that you already have created the class: Staff. It should be like what sciwizeh has suggested.
This is an example on how to read from the keyboard:

Staff [] staff = Staff[12] //this is an ARRAY. It is not null, but these are: staff[0], staff[1], ...
BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));

staff[0] = new Staff(); //staff[0] IS a Staff object.

String name =  keyboard.readLine(); //reads from the keyboard
staff[0].setName(name);
//read the rest of the elements that Staff should have

Use a for loop for the rest of the elements of the array

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I would suggest to look at this class: Logger

And search tutorials or examples, since you are interesting in log files

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

did i call your name mark my word cause you dont know who are you talking to dont under estimate my knowledge you might see your mistakes soon i suggest you to keep your mouth shot if you dont want to help!!!!

What do you mean, and to who are you referring to?

As for the formula, describing the Gauss algorithm is very long for this post. But, since I learned it in high school, you should be able to find it in most Math books, or the internet.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

There is a null personList of type List, but you declare that the null personList List will have ONLY elements of type Person.
The personList maybe null, it is type List but you put "things" in the List. And you declare that when you are going to put things in the List the elements will be of type Person.

List<Person> personList= null;

Then somewhere else in the code:

personList = new ArrayList<Person>();
personList.add(new Person());

//the following is wrong:
personList.add(new String("Aaaaa"));
//you can put only Person objects in the List

But this would be correct:

List list = new ArrayList();

personList.add(new Person());
personList.add(new String("Aaaaa"));

But not recommended

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You cannot show html in a JFrame.
javascript goes in html code.

html and JFrame are 2 different ways to create GUIs. The first needs a browser (and sometimes a running server) and the other a JVM

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Again no. html can be viewed only using a browser

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

If what you said made sense, the answer is NO.
Html is a tagged based "language" used to create web pages. Javascript (has nothing to do with java) is executed in your browser (to be exact is executed at the client but I don't know how else to explain it so you can understand it). Javascript does not need to be compiled.
Swing is java comipled and executed as an appilcation

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I don't think that this is possible. If someone else thinks otherwise, correct me.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

hello im john rico a com sci student could anyone help me to make a program that has three equation and three unknown pls.

You can either use Gauss as sciwizeh has suggested,
but if don't know the algorithm you can do it the old fashion way, by solving this equation on paper and programming the results:

a1*x+b1*y+c1*z=q1
a2*x+b2*y+c2*z=q2
a3*x+b3*y+c3*z=q3

By the way you have to show some effort before getting help.
I would suggest to create a method that take as argument the array with the values and return the new modified array

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I think applets is what you are looking for.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

hello pls help me i know that you can hepl me on how to make a program that has three equation and three unknown
pls A.S.A.P

Don't hijack threads. Start your own. Someone else started this thread to look for help; do you think it would be nice for people to start answering your questions instead of the one that started the thread?
And requests such as: "A.S.A.P" , don't work here

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You did a whole year of programming and no one taught you the simple algorithm for looping and finding the max number?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

If you want to give only once input the use the args of the main. This happens when you run the program

Use BufferedReader when you don't know how many inputs the user will give.
If you have a menu where the user selects options you don't know when the user will decide to stop selecting. So you will use BufferedReader. In that way you read input while the program is running

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Now pay REAL attention to this:

package testpackage;

/**
 *
 * @author stamatios.bardanis
 */
public class Main3 {
    public static void main(String [] args) {
        Person a = new Person("John");
        Person b = new Athlete("John", 178); 
        
        System.out.println(a.toString());
        System.out.println(b.toString());
    }
}

Both a and b are Persons:
Person a = ...
Person b = ...
And I call the same method:
a.toString()
b.toString()

BUT for object a, the Person toString() will be called.
For object b, the Athlete toString() will be called.
Check what the toString() methods of those objects do and what is called.

An Athlete object is a Person. Meaning it can do whatever a Person can do. The Athlete object has access to all the public methods of Person

But this would be wrong:

Athlete c = new Person ("John");

Because a Person is not an Athlete. The Person cannot call the Athlete's methods. How could it?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

And for inheritance:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package testpackage;

/**
 *
 * @author stamatios.bardanis
 */
public class Athlete extends Person {
    private int height=0;
    
    public Athlete() {
        super();
        height=0;
    }
    
    public Athlete(int he) {
        super();
        height=he;
    }
    
    public Athlete(String na) {
        super(na);
        height=0;
    }
    
    public Athlete(String na, int he) {
        super(na);
        height=he;
    }

    public void setHeight(int he) {
        height = he;
    }

    public int getHeight() {
        return height;
    }

    @Override
    public String toString() {
        return "The athlete: "+getName()+" has height: "+height+" cm";
    }
    
}
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package testpackage;

/**
 *
 * @author stamatios.bardanis
 */
public class Main2 {
    public static void main(String [] args) {
        Athlete a1 = new Athlete();
        a1.setName("Andersson");
        a1.setHeight(180);
        System.out.println("Name: "+a1.getName());
        System.out.println("Height: "+a1.getHeight());
        
        System.out.println();
        
        Athlete a2 = new Athlete("Superman",200);
        System.out.println(a2.toString());
    }
}

Check what I call. Then check the code of what I call and what it returns
Any questions?
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
package testpackage;

/**
 *
 * @author stamatios.bardanis
 */
public class Person {
    private String name=null;
    
    public Person() {
        name="";
    }
    
    public Person(String na) {
        name = na;
    }

    public String getName() {
        return name;
    }

    public void setName(String na) {
        name = na;
    }

    public String toString() {
        return "My name is: "+name;
    }
    
}
package testpackage;

/**
 *
 * @author stamatios.bardanis
 */
public class Main {
    public static void main(String [] args) {
        Person p1 = new Person();
        p1.setName("Andersson");
        System.out.println("Mr "+ p1.getName()+" welcome back. We missed you");
        
        System.out.println();
        
        Person p2 = new Person("Neo");
        System.out.println(p2.toString());
    }
}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
import javax.swing.*;
public class StackArray 
{
    private Object stack[];
    private int sizeIndex = 5;
    private int topPtr;
		
    public StackArray()
    {
        stack = new Object[sizeIndex];	//What is object?
/*As in VB6.NET everything is an Object (everything extends from Object). You create an array that will contain Objects and since everything is an Object you can put whatever you want inside it*/
    }
    
    public void push(Object stackItem)
    { 
        if(!isFull())
        {
        	stack[topPtr] = stackItem;	//What is Ptr stands for in topPtr?
        	topPtr++;		// why topPtr++?
/*
You use the int(eger) variable topPtr to point (nothing to do with C pointers) where the new element needs to be put in  the stack. You put a new item (stackItem) and you increase topPtr by one, because the new element will be put after the last one. Also the code checks if the stack (array) is full because since you simulate the stack with an array you can put unlimited things in the array.
*/
        }    
        else
        {
        	JOptionPane.showMessageDialog(null,"Stack is Full!","Error",JOptionPane.ERROR_MESSAGE);

        }      
    }
    
    public Object pop()
    {
    	Object x = null;	  // why x is initially null?
//You set it an initial value. If there is nothing in the stack then you will return nothing
    	if(!isEmpty())
        {
            x = stack[--topPtr];	//Why --topPtr?
            stack[topPtr] = null;
/*
Because topPtr determines where the next element will be put. So you since you want to remove the last element you decrease topPtr by one to take the last element. Also by decreasing you make sure a new element …
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Fist of all, as a concept do you know what stack is?
Do you know what this calculates to: + a b?

Stack is a structure where you put items in it one after the other and when you want to remove one you take the last one entered (LIFO). Like a stack of plates. You always take the one on top. Assume that you put letters in the stack:
put a
put b
put c.
Now you stack is like this:
| c |
| b |
| a |
-----
When you want to remove something you can only take c.

When you write + a b, it means a + b. You take the operator '+' and you apply it to the 2 next numbers. If next to the operator there is another operator you apply the next operator to the next 2 numbers and so on:

* - a b + c d
* - a b + c d
* (a-b) + c d
* (a-b) + c d
* (a-b) (c+d)
(a-b) * (c+d)

The whole concept is you put things in the stack and if they are digits or '+' you either add more or you remove to calculate:

Example:
* - a b + c d

>is d number?
>put d
>is c number?
>put c

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You haven't done this:
btnref.addActionListener(this);

And why do you do this:
txtamt1.setText(null)

instead of this:
txtamt1.setText( "" )

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Where in your program do you give value to the String variable Invoice? NOWHERE.
You dont' do this: Invoice = "someString"; so it returns null.
You have to give it value.
What do you want it to return? It is 3rd time I ask this.
Instead of this:

public String getInvoice()
{
return Invoice;
}

Remove the Invoice variable and calculate in the method the result and return it:


And MOST IMPORTANT: Don't declare variables with the same name as your class. It is bad programming. Variables should have the first letter lowerCase.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Do you declare Invoice somewhere in the Invoice class?

public String getInvoice()
{return Invoice; }

I assumed that when I set the setInvoice code, that the getInvoice statement returns the values in that format

No, the getInvoice will return the value of Invoice. If you don't give it value it will return null.

if I try to use "public String getInvoice((double subtotal, String customerType)" I get an type error.

If you declare getInvoice like this:

public String getInvoice(double subtotal, String customerType) {
  return "someString";
}

Then you call it like this:

Invoice inv = new Invoice();
String s = inv.getInvoice(5.00, "type 1");

You still haven't told me what you want the getInvoice to return.

Post the Invoice code only.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

What do you want getInvoice() to return? Are you sure you have posted all the code of the Invoice class?
It seems to me that the Invoice variable inside getInvoice() doesn't have a value, but I will need the rest of the code to be sure

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I really don't know. Never had to write something like that. Sorry.