jasimp 427 Senior Poster Featured Poster

What error message are you getting? After a quick glance through I think one of the more beneficial things you could do is separate your classes into separate files. You also appear to switch between myItem and myItemname when calling methods on your Item object.

jasimp 427 Senior Poster Featured Poster

When I made a chat application I had the same problem. If you had googled a little harder you could have found this solution.

//incoming is the JTextField that displays the conversation
//doc is a previously initialized Document object. 
doc = incoming.getDocument();
incoming.setCaretPosition(doc.getLength()-1);
jasimp 427 Senior Poster Featured Poster

is there any way i can get around this??

I presume you are trying to ask the user for input again? You should be able to set the text in the text field, but without seeing your code I don't know why it wouldn't work. Use a while loop to keep asking for input.

jasimp 427 Senior Poster Featured Poster

It says that class wk2 is never used and private static final char Y = 0 is never read locally and public void main(String[] args) { is never used locally

That is because you are using the Eclipse IDE (most likely). Those are not compile errors or exceptions. They are "hints" by the IDE. They each have their own little yellow line, right? It is best to understand the language before you use an IDE

jasimp 427 Senior Poster Featured Poster

@darkagn
Student does have all those methods because it extends JFrame.
@ComputerGirl
Are you sure you ran it? When I run it I see the window but other than that it doesn't do anything yet.

jasimp 427 Senior Poster Featured Poster

i'm new to this forum, i think u guys will tell me more about some things i don't know...cheers

Welcome! I hope you learn lots of new things.

jasimp 427 Senior Poster Featured Poster

Do you want a cookie or something?

Sure. I love cookies :)


@Serkan
Just give up the argument. Cheating is bad. It is as simple as that. Look at the definition of cheat, nothing good is said about it. You should have let the cheating thing die, now it's a zombie that wants to eat its master(you).

jasimp 427 Senior Poster Featured Poster

In your calcAverageBill() method you return monthlyTotal/monthlyBill.size(); When you initialize monthlyTotal you set it equal to zero, and then never change the value.
Did you mean to set monthlyTotal to sum after the for loop ran?

public double calcAverageBill(ArrayList<Double> monthlyBill)
    {

        
        double sum = 0.0;
        double monthlyTotal = 0.0;
        
        for(int i=0; i < monthlyBill.size(); i++) 
        {
			sum += monthlyBill.get(i);
	
          }
        //monthlyTotal still equals Zero here
        return monthlyTotal/monthlyBill.size(); 
}
jasimp 427 Senior Poster Featured Poster

Well, you should have added all those values in the tester method.

import java.util.ArrayList;
public class CO2FromElectricityTester

{

//main method
    public static void main(String[ ] args)
    {
        //initialization of variables
        double total = 0.0;
        
        //create object
        CO2FromElectricity CO2 = new CO2FromElectricity();
        ArrayList<Double> monthlyPrice= new ArrayList<Double>();
        monthlyPrice.add(0.1117);
        monthlyPrice.add(0.1107);
        monthlyPrice.add(0.1110);
        monthlyPrice.add(0.1113);
        monthlyPrice.add(0.1135);
        monthlyPrice.add(0.1138);
        monthlyPrice.add(0.1217);
        monthlyPrice.add(0.1215);
        monthlyPrice.add(0.1216);
        monthlyPrice.add(0.1228);
        monthlyPrice.add(0.1209);
        monthlyPrice.add(0.1192);

        
        
                             
        System.out.printf("Average Monthly Electricity Bill: %11f",CO2.calcAveragePrice(monthlyPrice));
                                                    
        }//end of main method
    
}

That is what the tester class should look like. The tester class should provide the values to the class you are testing. This way you can reuse the CO2 class. The same goes for the calcAverageBill() method. The point of passing a parameter to a method is so it can use the value(s) the parameter holds.

Your calcAveragePrice() method should look like this

public double calcAveragePrice(ArrayList<Double> monthlyPrice)
    {
        double sum = 0.0;
        double monthlyTotal = 0.0;

       for(int i=0; i < monthlyPrice.size(); i++) 
       {
	      sum += monthlyPrice.get(i);
       }

          return monthlyTotal/monthlyPrice.size();
    }
jasimp 427 Senior Poster Featured Poster

You created the method

calcAverageprice(ArrayList monthylPrice)

Then you call the method in your tester class without passing the ArrayList parameter

calcAveragePrive()

Also, as a side note, in your tester class you forgot the 'i' in import java.util.ArrayList;

jasimp 427 Senior Poster Featured Poster

Try to parse the number as a double. If an exception is thrown clear the text field and request that the user input a valid decimal number.

Read the other posts before posting. That is exactly what I said.

jasimp 427 Senior Poster Featured Poster

old threads do host an announcement saying that "This thread is more than three months old - Perhaps start a new one."

And how often is that followed. Here is an example of a member who just joined, and wants to be helpful. They "answered" a question from a thread more than three years old. However they realized the thread had already been answered, and edited their response. Now it is going to be on the shoulders of 14 people to tell all the members like mezzin, to check the dates. Maybe the workload on moderators will not increase as much as I think it will. If Dani doesn't mind adding it, and moderators workload does not greatly increase, I would support a Sage feature.

jasimp 427 Senior Poster Featured Poster

I'm not sure if there is a way to restrict JTextBox to only numeric values. What I would do is have the user input the data, then parse what every they input as a double. When you do that the decimal will be considered part of the number. When you parse, check for a NumberFormatException, if one is thrown the user most likely inputed letters, ask them again for the data.

jasimp 427 Senior Poster Featured Poster

The problem I see is when someone (most likely a new member) posts to an old thread, asking for help, no one will see it (always imagine the worst case scenario, in this case it is every regular member has "Sage" mode turned on) and they will never receive an answer.

jasimp 427 Senior Poster Featured Poster

I didn't want to post my full code because it's too long and confusing to explain so I made a pseudo-version of it.

Writing code that only you can read is a bad habit to get into. However, you made the right decision to not post it because of the length.

jasimp 427 Senior Poster Featured Poster

I finally got around to linking a website to my posts, but it's not showing up. I typed in the website URL in the "Home Page URL" box in my Control Panel, but I'm not seeing it on my posts. Did I do something wrong?

I didn't know it was supposed to appear on posts. If I click on your username, I have the option to visit your homepage.

jasimp 427 Senior Poster Featured Poster
boolean display = A.B(inputInfo);

The return statement you used is legal. You can return false, true, or a boolean variable when using a boolean method. When you call A.B() that line of code becomes (basically anyways) the data type you are returning. That is why if you have a method that returns a String you can say

String testString = Class.returnMethod(someVariable)

As long as returnMethod() returns a String, the above code will work. The same concept applies to your situation.

jasimp 427 Senior Poster Featured Poster

I know this is a beginner question but it is something that I have never had to do before. Is this the correct way to import the other classes?

Why would you do this in your GeometricObject class? Just create a driver class, here's the one I made.

public class Tester {
public static void main(String[] args) {
	Triangle tri = new Triangle(56,56,56);
	System.out.println(tri.perimeter());
	Isosceles iso = new Isosceles(56,56);
	System.out.println(iso.perimeter());

}

}

Creating a driver class just tests code from other classes you have built. Your GeometricObject class is an abstract class and has no need to import the other classes because it never uses them. I'm pretty sure that if you keep your Java files in the same folder, say "/Java Code/Geometric" when you compile them the compiler will find all the classes it needs.

Grn Xtrm commented: Thanks for walking me through the process. +1
jasimp 427 Senior Poster Featured Poster

If all that code is one Java file than that could be the problem. I separated each class GeometricShape, Triangle, Isosceles, Equilateral, into it's own file and had no trouble running a driver class creating each type of triangle.

jasimp 427 Senior Poster Featured Poster

hi
how i can do this by StringTokenizer

Is there a more easy efficient method?

Easy is relative, what might be easier for some could be really hard for you.
Google StringTokenizer examples, read the API and then start writing some code. When you have shown some effort come back, post your code and ask a specific question.

This tutorial should get you started.

jasimp 427 Senior Poster Featured Poster

Amazing. Visiting the Geeks' Lounge is like sitting in a room full of children.

Maybe you should lobby to follow up on Rashakil's suggestion, Day Care, but instead of creating a new forum, just rename this one :)

Ancient Dragon commented: Nice suggestion :) +36
jasimp 427 Senior Poster Featured Poster

The String class has a replaceFirst() method, look into it.

jasimp 427 Senior Poster Featured Poster

Why?

I must be too stupid to figure out why you think I don't have a sense of humor? Although your old age of 95 might have something to do with it ;) My post wasn't supposed to be taken seriously anyways; I had been following this little "game" of yours and serkan's for the past few days and found it interesting. I thought the Geeks' Lounge would be a much better forum to comment on it than in the tech forums.

jasimp 427 Senior Poster Featured Poster

Rashakil Fol,
What don't I have a sense of humor about? You should have been more specific.

jasimp 427 Senior Poster Featured Poster

Hope that helps.

It doesn't help because you just threw code at the OP, didn't offer any explanation to what you changed and didn't even show what you fixed. You should point the OP in the right direction instead of thrusting code at them.

jasimp 427 Senior Poster Featured Poster
public Triangle(double s1, double s2, double s3)
	{
		this.side1=s1;
		this.side2=s2;
		this.side3=s3;
	}
	

	
	public Isosceles( double EQside, double otherside)
	{
		super(EQside, otherside); //calls triangle constructor 
	}


	public Equilateral(double side)
	{
		super(side); //calls isosceles constructor. 
	}/

Look at all your constructors. You have one triangle constructor, and it takes three parameters. Then in the Isosceles constructor you call super() with two parameters. You made the same mistake in the Equilateral constructor.

jasimp 427 Senior Poster Featured Poster

Your beautiful hands turn me on...

I'm going to make it so dry for you.

I think your attempt of "[making] [his] existence on this forum a miserable one." isn't working. He seems to be posting more often.

http://www.daniweb.com/forums/post818433-15.html

Rashakil Fol commented: You have no sense of humour. -2
nav33n commented: You do have sense of humour ;) +10
jasimp 427 Senior Poster Featured Poster

hello!! is there any body to answer my question :
is "General List" a data structure(like ArrayList for example) in java language??if it is, plz tell me what it exactly is??I have searched but i didnt find anything about it!!

Don't use extra punctuation(such as !!!! or ???) next time.

There is not a "General List" data structure, there is a "List" though. This link you should be helpful.

jasimp 427 Senior Poster Featured Poster

i want to see the names for the poster titles, the ones starting from newbie to ... . is there any complete list of them?

This question has been asked so many times before. There is no list because Dani wants it to be a surprise, of sorts.

i also want to know what are the roles of moderators, super mod, staff writer, administrator and so on.

Here is the list of moderators, super mod and administrators, plus the links to the other groups. I'm sure one from each group could tell you their exact responsibilities, if they wish too. But moderators make sure the rules are followed within the forums, super mod has the power to change all sorts of things, the admins don't do anything (just kidding ;) and I think Team Colleagues are past moderators.

jasimp 427 Senior Poster Featured Poster

I hope you don't mind but I changed your PrintStream to

BufferedWriter os = new BufferedWriter(new FileWriter("output.txt"));

BufferedWriter has an overloaded method write(), one parameter this method takes is a char[].

Now your write code looks like

for (int i = 0, z = leng - 1; i < leng; i++, z--) {
      Xnew[i] = x[z];
}
 os.write(Xnew);
 os.close();
jasimp 427 Senior Poster Featured Poster

keeping a diary is a good thing, keeping it away from other people is hard..

It's especially hard when you tell the world what is inside ;)

jasimp 427 Senior Poster Featured Poster

Auditory : 60%
Visual : 40%
Left : 63%
Right : 36%

Jasimp, you are mildly left-hemisphere dominant while showing a slight preference for auditory processing. This overall combination seems to indicate a well-working blend of logic and judgment and organization, with sufficient intuition, perception and creativity to balance that dominance.

You will at times experience conflict between how you feel and what you think which will generally be resolved in favor of what you think. You will find yourself interested in the practical applications of whatever material you have learned or whatever situation you face and will retain the ability to refine whatever knowledge you possess or aspects of whatever position you are in.

By and large, you will orient yourself toward intellectual activities and structure. Though not rigid, you will schedule yourself, plan, and focus on routine and continuity of operations, rather than on changes and disruptions

When changes or disruptions occur, you are likely to consider first how to ensure that such disruptions do The same balance is reflected in your sensory preference. You will tend to be reflective and measured in your interaction style. For the most part, you will be considered objective without being cold and goal-oriented while retaining the capacity to listen to others.

Preferentially you learn by listening and maintaining significant internal dialogues with yourself. Nevertheless, you have sufficient visualization capabilities to benefit from using graphs, charts, doodles, or even body movement to enhance your …

jasimp 427 Senior Poster Featured Poster

Iv uploaded the code so far on rapidshare if you could just download it and check it out that would be greatly appreciated, it dont seem to compile...

You need to post the section of code that is giving you trouble here, not the whole thing, only where you are getting an error (don't forget to tell us what error/exception you are getting.) A great skill to have is the ability to go through your code and figure out why "it don't seem to compile", if you ask for help every time the answer doesn't dance around naked in front of your face, you'll never develop that skill.

verruckt24 commented: I like the way you say this, straight to the face +3
jasimp 427 Senior Poster Featured Poster

When I programmed Blackjack I used an ArrayList to hold all my cards. To shuffle I simply had a for loop run about 1000 times, randomly picking a number 0-51, removing the object at that spot while at the same time adding it to the end. Just another idea for a shuffle 'algorithm'. I wouldn't use this with a lot of elements but with 52 it works well.

public void shuffle(){
for(int i=0;i<1000;i++){
	int rand = (int)(Math.random()*50)+1;
	deck.add(deck.remove(rand));
        }
}

It took about 0.003169118 seconds to shuffle.

jasimp 427 Senior Poster Featured Poster

To print the IP address of a client use

System.out.println(clientSocket.getInetAddress().toString());

It will print the Ip address in this format /XXX.XXX.X.XX >>How can i interpret this?

It depends on what you want to do with the IP address or hostname.

jasimp 427 Senior Poster Featured Poster

Chili con carne, homemade bread and a glass of California blush Zinfandel.

That sounds so good! I think you should share some with me ;)

jasimp 427 Senior Poster Featured Poster

what u mean ???

He means do it yourself. Once you start writing and come across a concept you don't understand, ask for a little help (in the correct forum.)

Killer_Typo commented: pretty much +7
jasimp 427 Senior Poster Featured Poster

Please help I am stuck. I am trying to retrieved text from a file named "text.txt" and reversing the contents to another file named "output".

Your code doesn't even attempt to write to a file. It only reads. Try to write to the file and if you're stuck, show us your new code.

jasimp 427 Senior Poster Featured Poster

Thanks for the recommendation but I did say that I didn't really like it :P And yes, I did read it a little...

Doh! From now on I'll have to read all the way through posts, instead of just skimming the really long ones ;)

jasimp 427 Senior Poster Featured Poster

I personally recommend Head First Java.

jasimp 427 Senior Poster Featured Poster

a thread titled Do you Believe in evolution has to be a 'god thread' somewhere in its passage

It does not have to be a argument over God, which turns into a flame war, like this infamous thread. Although with Josh no longer here maybe a thread like that would not be 145 pages of insults.

jasimp 427 Senior Poster Featured Poster

I was wondering when this would turn into a god thread... :-/

Rashakil Fol commented: Every post you make bumps the thread to the top. -2
jasimp 427 Senior Poster Featured Poster

So how did TooStep get an email address that I only typed once in my life, when I signed up for daniweb?

Internet magic ;)

jasimp 427 Senior Poster Featured Poster

Have you noticed the evolution of the Simpson family -- now that they have been around for 30 years, they have started to insert lots of stories that explain what happened between marriage and kids.

Wrong. They were doing that in the early seasons, at least before season seven, possibly as far back as season four; and they've completed nineteen seasons (almost done the twentieth) plus three more on the The Tracey Ullman Show; 22 years old on April 19th.

It is entirely possible I misunderstood what you meant by "that explain what happened between marriage and kids" but almost every major character's entire life could be mapped out by season 10.

jasimp 427 Senior Poster Featured Poster

Hasn't The Dude already been featured as a member of the month?

At first I thought so too; but I think it's Nichito we're thinking of.

jasimp 427 Senior Poster Featured Poster

Been that way for a while

I don't know how long ago it was changed but Comatose, up until ten days ago, hadn't posted since March 2007, almost two years ago.

jasimp 427 Senior Poster Featured Poster

Please use code tags, if you wish us to go through the code.

Since his code is so long he should give us only the part that is giving him trouble, then if we need more we can ask for it. Posting all that code in the OP isn't good etiquette, it my opinion

jasimp 427 Senior Poster Featured Poster

Can anybody send me the source code in JAVA platform for Networking monitoring

We don't hand out code, or much help, without effort. Your question is too vague to be answered (or perhaps 'Network Monitoring' is a very specific and I haven't heard of it.)

jasimp 427 Senior Poster Featured Poster

What do you mean?

There isn't multiple inheritance in Java. It's a single inheritance only language. :)

That's what javaAddict said, Java does not have multiple class inheritance, you can only only extend (is-A) one class. However you can implement (has-A) any amount of interfaces you want.

jasimp 427 Senior Poster Featured Poster

I am going to let my cat post

From the looks of your post your cat must be thinking about sleeping; all those z's.