stephen84s 550 Nearly a Posting Virtuoso Featured Poster

According to me this is what is causing the problem :-

int mat1[][];

You have never initialized your matrix, with any size.
You will have to initialize your matrix as follows to be able to use it:-

int[][] mat1 = new int[3][4];

Heres a tutorial to help you on arrays.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Edit your post, the code tags go in square brackets ([) not angled brackets, like here:-

[code=java] // Your code goes here

[/code]

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I cannot see at what point you have put a System.out.println() for "value is2". Also show us where and how the method "accept()" is being called and how the matrix is being initialised.

Also I guess it would be nice if you would "close()" your BufferedReader, once you are done using it in that method.
The developers did not give the BufferedReader class a "close()" method just for displaying in the javadocs.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

HTI


Exploring information on Space,Universe, Heavenly bodies etc ?

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

-1150

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

national nation ton

bubble

stephen84s 550 Nearly a Posting Virtuoso Featured Poster
String myString = Integer.toString(enter);
			
return enter;
return output;

You completely missed the point I was trying to say. I had told you to package both those values into a String array and return a reference to that array back to the calling method, like here :-

String[] arrayOfValues = { output, Integer.toString(enter)};
return arrayOfValues;

Also you will have to modify the return type of your method to accommodate that.
BTW didn't the compiler complain about unreachable code ???

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Show us what you tried ?

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I need both the 'output' and 'enter' to be returned back to the calling method but one is a String and one is an int

You have many options here one is create a new class which has those two as its member properties and return a reference to this object from that method.
Second is put them both inside a "String" array of size "2" and return a reference to that array from the method and in the calling function extract the values from the array. For ex in the method you could have :-

String[] arrayOfValues = { output, Integer.toString(enter)};

And in the caller method you could extract the values from the "String" array as :-

output = arrayOfValues[0];
enter = Integer.parseInt(arrayOfValues[1]);

Next you could also return a Properties (or some other classes part of the Collections Framework ) object with the appropriate name value pairs mapped in it.

olgratefuldead commented: Very helpful +1
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Give us more information on what libraries are you trying to use in that applet and what platform are you trying to run this on. I have a strong **feeling** you are not on windows or not using the Sun JRE (of course I could be wrong).

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Very Hard to do that.

Do Lipton employees take coffee breaks ?

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

What no new word ?

Ok I will go then :-

award

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

why the oocupancy rate is always zero after i compile?

After you "compile" your program none of your variables have any values in them and none of your methods are executed.

It is only when you run the program all the fancy work of variables being initialised, methods being called, objects being created etc happens.
As far as your program goes, tell us what the following line prints:-

System.out.println("The total rooms occupied in the hotel is "+totalOccupied);

If that prints "0" then its a case for simple arithmetic that "occupancyRate" is zero because of :-

occupancyRate = totalOccupied / totalRooms;

However the most probable fault is the fact that you are dividing an "int" by another "int" so the result would be an "int" with the decimal part truncated which you are assigning to a double.
You will need to either declare your variable "totalOccupied" either as double or cast it as a double while performing the division operation, if you want the decimal part of the result to be preserved.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Hate it.

Repeating questions ?

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

No

is the world truly flat ?

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I am very naive to java.

So buy / borrow / steal a book on Java read it (there is also the "Starting Java" sticky which should interest you) and get up to speed on it. I think your class instructor / firm would have given you this assignment only after they were **sure** that you could handle it. However if you gave them a false impression of your skills then I do not know .....

do i have any packages in java to implement this

Weka is a data mining tool written in Java, so you might want to check out how it works. I however have never used, so do not have a clue about it.

please help to code in java

Help yes, but do not expect us to do the entire work for you. First you show us what you have tried. Reading data from a CSV file is simple enough show what you have achieved there ??

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Relative paths are quite easy. Now you know your working directory is :-

C:/Program Files/glassfish-v2ur2/domains/domain1/config/

But you want the file located at :-

D:/Programs/Java/JasperReports/EmployeeReport/web/WEB-INF/reports/employeeReport.jrxml

One thing to remember in relative paths is ".." indicates the parent directory.

Try using the following path to access your file:-

../../../../Java/JasperReports/EmployeeReport/web/WEB-INF/reports/employeeReport.jrxml

But you might want to check if theres a better way to get it to work.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Please write java code for me.

????

Are you sure you have gone through the rules even once ???


Here some of them quoted specially for you :

Also, to keep DaniWeb a student-friendly place to learn, don't expect quick solutions to your homework. We'll help you get started and exchange algorithm ideas, but only if you show that you're willing to put in effort as well.

And a link to the announcement.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

@vishalsnc

Drop the IM speak this is not a chat room, and try to read the rules and search the forums before you post anything.

cn u pls mail me some examples if u have ..

What do you think does the Sticky which Peter has linked to contain ???

nw hw to convert that to MVC2 pattern..
like which files are to be made and hw the content is to be seperated n all..

There is no magic bullet or a step by step guide which you can follow and "Viola !!! your application has been converted to MVC2". Peter has linked you a good example with proper explanations. Think over it and redesign your classes and JSPs with MVC2 and the example as a reference in mind.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

We will first need to find out your current working directory. For that using the File class, in your JSP page create a new file as :-

File f = new File("temp.txt");
out.println("New file created : " + f.createNewFile());
out.println("Absolute path of File : " + f.getAbsolutePath() );

The second statement will give you the absolute path where the file was created, note that path excluding the "temp.txt". All your paths should be relative to the directory in which temp.txt was created.

Of course there could be other ways but I do not have any info on Glassfish + NetBeans combo.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

ui,anu n?

Read the rules and stick to using the English language

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

fire ire bug

trench

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

What I have simply spits out the multiplication tables from 1 to 12.

Now if you have the above, then all you need to do is get the user to input (using Scanner or Console or BufferedReader and just before your "for" loops starts) from the Console up to what value he wants the tables to print and just replace 12 with that variable name.

Also as far as formatting your output is concerned you might want to look at the System.out.printf()[Resources : 1,2,3] method.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Now considering the piece of code that you say causes the problem :-

while(true){
  key = get_random(new BigInteger("100"));
  if((key.multiply(E)).mod(P_min_1_into_Q_min_1).
      equals(new BigInteger("1")))
    break;
}

Now from what I see, what **I think** is happening is that your "if" condition is never getting satisfied as a result of which your program goes into an "infinite" loop giving you the feeling that it has hung up.

My suggestion is put a System.out.print statement just in front of your "if" with its contents as the "if condition" so that you can visualize what is actually the state of your variables or where your values are drifting off track.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

The following is the piece of code that is giving you the problem :-

ArrayList person=new ArrayList();

Since JDK 5.0 you have to specify what kind of Objects your ArrayList is going to store.
For ex in you case it appears to be objects of class "PersonInfo".

So your code would be modified as :-

ArrayList<PersonInfo> person=new ArrayList<PersonInfo>();

But the last time I checked the compiler only gave me a warning not an Error.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I think he is just spreading them.

Will the next person concur with me ?

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

-1148

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Whose fault is it? What does that mean? That's just the way my life is...Unfortunately, I'm not as privileged as you seem to be.

Our Lives are the way they are because of the choices we make and hence we are responsible for them. As far as privileges go, you do not even have a clue about how I have got to the place I am at.

Take a step back before you start criticizing people.

You were expecting us to take piety on you and hence provide you with a solution and I just calmly pointed out your faults back at you.

This is my main issue with this field is that it is filled with arrogant people like yourself.

Who do you even think yourself to be to judge me or anyone in this field ?? You are a person who does not even want to be held responsible for your own actions which have got you in this mess in the first place.
If instead of just complaining about your life's problems if you would have concentrated on getting a solution or providing us with complete information about your code you would have had your program working already.

Good day to you sir.

You too have a nice day.

And this will be my last Off Topic response, I do not wish to dilute the information I provided on this thread to help you with counter arguments against your meaningless blabber.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

HTI

Flying ?

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Then the first thing you need to know is "temp" should just be of type Object, and initialize it to null. You do not need a temporary array of objects.
Next thing is you can reverse your data with just one "for" loop, I think the second loop is messing it up. The fundamentals for reversing are quite simple.

  • Set k=0
  • Set temp = array[k]
  • Set array[k] = array[size-k]
  • Set array[size-k] = temp
  • Increment k
  • If k < Size/2 Go Back to Step 2

It's tough to find time to get help outside of class

So ask the questions in class.

I work full-time and I am a full-time student.

Now whose responsible for getting yourself into that situation ??

After this I'm done with programming.

Then why did you take it up in the first place ?

stephen84s 550 Nearly a Posting Virtuoso Featured Poster
public void reverse() {
  Object temp = new Object[INITIAL_CAPACITY];
  ^^^^^^^^^^^^^^

  for(int i = 0; i < size; ++i) {
    for(int j = size; j > 0; --j) {
      temp = data[i]; 
      data[i] = data[j];
      data[j] = temp;
    }
  }
}

Check the highlighted section you are actually assigning the reference of an array of Objects to a "reference" of type "Object".
By the way what is "size" would you care to explain ?

...I'm afraid to speak up in class so I'm asking here.

So rather than make full use of the cash you paid for that class, you would rather keep your pride intact and run helter-skelter for the solution ??
I suggest you speak up in class and let your instructor know at what level you are. Also you might find that the others are not as "hot shot" and just like yourself, or maybe you could befriend one of the hot shot kids and learn from them, I myself picked up most of my logical analysis skills, debugging skills from my "hot shot" peers.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

A request to the moderators please lock this thread as I doubt anything related to original post is bound to be added here anymore and for no reason at all is being brought on the first page repeatedly.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

596

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

for rum or

strait

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Well if you observe correctly then the link in the last poster name on the thread list page is like this:-
http://www.daniweb.com/forums/member.php?find=lastposter&t=176943

Whereas the Member Profile link is like this:-
http://www.daniweb.com/forums/member181595.html

@Ancient Dragon
You might want to check the following post in the Member of The Month thread.

I would nominate ArkM due to his excellent help in the C and C++ boards (I don't know where else he is at).

ArkM actually links to someone else's profile page and from the link it looks like it was picked from the thread list page.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Show us some code so that we can figure out what you are talking about.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

For mailing you can check the Java Mail API..
For writing the reports to an Excel proprietary format you will need Apache POI I guess.

Now for it to get automatically fired, I guess you need to create a small application (maybe in Core Java) which will run round the clock, and at specified time intervals (specified in its configuration file or maybe in the database) will fire a request on your JSP page using the required parameters. So for this you will need to know how to perform an HTTP Post / Get request on a remote URL via Core Java, so here is an example on that.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

First define what do you mean by "but it doesnt run. " Any exceptions, run time errors etc ?

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Simple at the start of actionPerformed() itself put an "if" statement like this :-

public void actionPerformed(ActionEvent e) {
  if(e.getSource() instanceOf JComboBox)  {
    // Code to execute for Combobox
  } else  if (e.getSource() instanceOf JButton){
    // Code to execute if Button clicked.
  }
}

Or else if your comboBox and button objects were declared at the class level itself, you can check directly which component generated the event as in :-

Class XFrame extends JFrame implements ActionListener {
  JComboBox abc;
  JButton btn;
  public XFrame() {
    super("Test Frame");
    abc = new JComboBox........
    btn = new JButton.....
  }

  public void actionPerformed(ActionEvent e) {
    if(e.getSource() == abc) {
      // code to execute when combobox abc generates event.
    } else if (e.getSource() == btn){
      // code to execute when button btn generates the event
    }
    else ....
    // event handling for other components
  }
}

** Note the code is just for illustration.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

The first results in 41 while the second results in -9 when the expected shud be 6.

Thats most probably happening due to overflow. To illustrate this simple fact try compiling and running the following code snippet:-

class OverflowDemo {
  public static void main(String[] args) {
    short a = 32767;
    a++;
    System.out.println("a = " + a);
  }
}

The above chunk of code on compiling and executing would give the following output :-

stephen@steve:~/Development/java/daniweb> javac OverflowDemo.java
stephen@steve:~/Development/java/daniweb> java OverflowDemo
a = -32768
stephen@steve:~/Development/java/daniweb>

Here when we added 1 to "a", we exceeded the capacity of "short" and it rounded off to -32768 due to overflow, similarly Math.pow(41, 77) exceeded the capacity of int.

Try casting the value returned by it to "long" to see if it fits there. If long also throws an error then the best option would be to use the BigInteger class where you will not be faced with any restriction on the value it can hold.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

If you use the showInputDialog() method, it either returns the String that was entered in the text field or else "NULL" if cancel was pressed, So in case you wish a User to force some input and not press Cancel, you could simple put it in a do-while loop like this:-

String StudentClass = null;
do {
  StudentClass = (String)JOptionPane.showInputDialog(null, "What class is " + 
      "\nthe new student in?", "Info", JOptionPane.PLAIN_MESSAGE, 
      null, possibilities, "IB Compter Science");
   System.out.println(StudentClass);
}while(StudentClass == null);

However if you use showOptionDialog method, and pass the "possibilities" array for the "options", you would get three buttons with their corresponding headings as specified in the Array.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

In case you do not want your user to press "Cancel" in a JOptionPane dialog, you can actually get rid of that button altogether using the JOptionPane.showOptionDialog()

<EDIT> Cleaned some of my errors.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster
JComboBox Oone =(JComboBox)e.getSource();

The above is the statement that is most probably throwing the exception, most probably you have added this same ActionListener to another UI component such as a button or a textfield etc (which could not / cannot be cast into an object of type JComboBox) and hence the JVM threw the ClassCastException when that object generated some ActionEvent.
Also next time please paste the complete exception stack trace as it helps us identify which is the exact line on which the exception was thrown rather that us having to scan through the code figuring out from which lines the Exception could have originated.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

in C++ which will print the memory address of the someVar. then how we can do it in Java?

Why are you obsessed with printing memory addresses, when you can accomplish your linked list with "references" in Java.
<EDIT>

I willl just put a simple example here of how a simple node of a linked list can be implemented:-

class Node {
  int data;
  Node next;
}

Hopefully this will make it more clear. You can also check out this and this for some more explanation on how "references" are handled in Java.

Ezzaral commented: It will sink in eventually :) +18
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

From what I see, unlike the rest of the variables (mass, diameter and names which are all arrays) surfaceGravity is just a normal variable.

Hence the following for loop:-

for (int y = 0; y < 9; y++) {
  surfaceGravity = (((6.67E-11) * (mass[y])) /(Math.pow(diameter[y] / 2, 2)));
  System.out.printf("%25.2f\n", surfaceGravity);
}

Actually does nothing but print the values of surfaceGravity from 0-9.
However the value of surfaceGravity variable are overwritten in the next iteration of the for loop. i.e. for the first iteration your loop calculates and stores the value of surface gravity for the first planet in variable "surfaceGravity", in the second iteration the we calculate the surface gravity for the second planet and store in the variable "surfaceGravity" (as a result the value for the surface gravity for the first planet is lost, overwritten by this new value) this goes on till the nineth planet (which is where the "for" loop terminates hence its value is not overwritten), and hence "surfaceGravity" has the value for only of the nineth planet.

My suggestion from the way your program has been designed is move the call to the "printResults()" method inside the second last "for" loop in your main.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

If you are not aware then there is a soft form of pointers in Java only they are called "references".

Whenever you create an object in Java as :-

Alpha var1 = new Alpha();
Alpha var2 = var1;

"var1" and "var2" are actually references to the same object of class "Alpha". Try some small programs you will figure it out.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Hijacking his own thread, this has to be the first of its kind. Anyway I have posted links to tutorials /articles on how to generate WAR files using maven in your "other" thread.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

maybe..

no.. Garfield is raising his one arm

There we go you used the forbidden words.

Am I crazy?..

From many of your earlier posts I deduce so.

Is the use forbidden words truly forbidden ?

stephen84s 550 Nearly a Posting Virtuoso Featured Poster