stephen84s 550 Nearly a Posting Virtuoso Featured Poster

@nandomendoza
Better start using code tags, with already 14 posts you should by now be aware what they are and how to use them, else the days not far before someone gives you bad rep for not using them at all.

Its as simple as putting your code inside [code=java] and [/code].

And as far as your code is concerned what is "SavitchIn" here :-

str1 = SavitchIn.readLine();

I am sure that you must be aware that you need to declare and initialise any variable in Java before using it. Most probably I assume this is a BufferedReader object for reading text from the console.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

A java.lang.NullPointerException is a pretty common problem, you need to show us your code if we are to help you in any way.
Also in the StackTrace that you have pasted, highlight to us the lines which belong to your ".java" file.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Please dnt joke .... u r from mumbai?? me tooo.. we can talk on the issue if u dnt mind ... please send the code sample.

You're from Bombay that nice to know, but that does not mean I am going to spoon feed you any code. My first post in the thread links to the iText library and the Apache POI site, go visit them and you will find quite a few code samples there.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

can you please help me with sample code that have both apache POI and itext used say for eample reading an excel and converting it into pdf. please hurry ....

Yeah before that transfer a million dollars to my account !!!

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I suppose JNI (The Java Native Interface) is what you are looking for.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Oh and as to why I didn't repost, I've been too busy with work to check how this turned out.

**yawn** I have seen this lame excuse from you in another unrelated thread so do not expect us to fall for it.
And by the way if you are not aware, you can figure out the online users viewing a thread, by just scrolling to the bottom of the page, which helped me figure out that you had no genuine reply to our posts and needed the extra time to manufacture this one.

I did not want to post in this thread especially after Peter's second response but just wanted to finish this argument off.

Someone close this.

+1 to that.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

618

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

616

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I have not visited the link but you might be interested in the JMonkey gaming engine for designing/implementing your game.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I always like to give the benefit of the doubt. The OP might not go to that school, and accidentally found about that site, searched it a little and found that assignment and decided to post it.

Unlikely but possible

I too was secretly wishing that this wasn't some attempt at disguising homework, but the fact that the O.P. after reading the first two responses from me and you didn't dare post again (even though I saw him as one the viewers of the thread at the bottom), gives a clue as to what he was trying to do.

Note:-

  • I still hope that I am wrong.
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

610

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

This tutorial should hopefully answer most of your questions.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Well maybe this might just be an error you made while writing this post, but "WEB_INF" should be "WEB-INF".
Apart from that at first glance I do not see anything wrong here.
Also you could try changing the import statement to "view.*" and observe what happens !!!

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

So answering to this thread would be just showcasing my Java skills as opposed to helping anyone ????

or

Is this a way of disguising your homework ??

or

Is this an assignment which you have copied from the NET and trying to get us to explain the code to ???

Well in the first case I do not have anytime for it and in the second case show us how much effort you put in tracing the execution path and for the third case forget about getting any help.

Salem commented: Works for me :) +29
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

i am pretty sure you got that backwards there stephen.

"For example I would enter 12345 and 1 2 3 4 5 would be returned."

I was assuming that is some mistake my the O.P. cause that "split()" method of python too does not operate in that manner but I could be wrong.
Thats the reason why instead of using his first post I quoted his Python post.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Coming from python, to split a string i would do 'string.split(" ")'
and it would split 123 into 1 2 3
I don't know .length, or .charAT, or what that even is
I do not know what I should use to traverse through the string and split it by each space, I know this is simple, but for some reason can't figure it out.

In Java too its just the same thing :-

String alpha = "A B C 1 2 3";
String beta[] = alpha.split(" ");

The values is "beta" would be the following :-

beta[0]="A"
beta[1]="B"
beta[2]="C"
beta[3]="1"
.... I suppose you get the drift.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

The following code snippet opens the a new Pop up window, with the specified title in the child window.

File : popupparent.html

<html>
  <head>
    <script language="javascript">
      function openPopUp() {
        window.open("popupchild.html");
      }
    </script>
  </head>
  <body>
    <a href="javascript:openPopUp()">HERE</a>
  </body>
</html>

File : popupchild.html

<html>
  <head>
    <title>HELLO</title>
  </head>
</html>

Title of the new Window was "HELLO"

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

So there was already a thread for it, why did you need to create a new one ???

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Hmmm ........... if you might not have noticed, there is a sticky at the top of the thread list called "Starting "Java" [Java tutorials / resources / faq] ".
Your questions have already been answered there along with tons of other useful resources.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Well yes it seems strange, BTW did you try setting the title of the pop up window using the title tag (<title>), in the page(JSP, Servlet, etc) which you wish to open in this pop up window.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I got the problem. It is not with the Random class at all. In fact it is associated with your "Circle" class.
Observe the following code of your Circle class:-

public class Circle
{
  public static int left;
  public static int top;
  public static int radius;

  public Circle(int l, int t, int r) {
    left = l;
    top = t;
    radius = r;
  }

  public String toString() {
    String Center = "(" + left + "," + top + ")";
    return Center + "      " + radius;
  }
}

You have declared all your member variables as "static". Because of that only one instance of "left","top" and "radius" is created. And it is this instance that is referred to from all the objects of the Circle class.
Drop the static modifier from all your member variables and your program should work fine.
You can read more about the static keyword here.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

i'm not 100% on this, but unfortunately there is no such thing as a "random number", progmatically anyway.

Correct this concept is called as Pseudo Random Number generation. If you continue to keep on generating numbers after a while you will observe a pattern emerging indicating they are not random hence the term Pseudo - false.

@kbullard516

I do not understand why are you not getting any change in the values. I tried the following sample program and the output is there below it:-

// An example to get a feel how the Random number generator works.

import java.util.Random;

class RandomExample {

  public static void main(String[] args) {
    Random r = new Random();
    for(int i=0;i<10;i++) {
      System.out.println(i + ": " + r.nextInt(99) + " ");
    }
    System.out.println();
  }
}

The output:-

stephen@steve:~/Development/java/daniweb> java RandomExample
0: 47
1: 43 
2: 50 
3: 1 
4: 81 
5: 70 
6: 43 
7: 20 
8: 70 
9: 0
stephen@steve:~/Development/java/daniweb>

As you can see it works correctly.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

ban bin win dine

hilarious

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

The problem you see is over here :-

int lim = 9;
public static Circle[] cArray;
    
static Random generator = new Random();
static int left = generator.nextInt(99)+1;
static int top = generator.nextInt(99)+50;
static int radius = generator.nextInt(50)+1;
          
public Collection() {
  for (int count = 0; count <= 9; count++) {
    cArray[count] = new Circle(left,top,radius);
  }     
}

Instead of generating the random values for every object of Circle you create, you are actually just getting the random values once and then assigning the same value to all your Circle objects.

You will need to move the code where you generate the random values to inside the for loop so that a new value is generated for every circle object.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Just observe the following code snippet:-

if(send = true) 
  cout <<"You have passed the exam!\n";
else if (send = false)
  cout <<"You have failed the exam.\n";

Watch both the conditions carefully you have used only a single "=" instead of "==" to test for equality.
BTW some compilers in this situation would complain of "Possible incorrect assignment".

Also there is no need for passing the second argument "pass" to your grading function, instead just declare a local variable in the "grading()" function and return its value.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

The problem sillyboy is referring to kbullard516 is related to the following code snippet.

public static Circle[] cArray;

You have never initialized the array "cArray", so memory will never be allocated to it, but you are still trying to put some values into that "cArray" in the Collection class as shown below :-

cArray[count] = new Circle(left,top,radius);

It is similar to the real life situation of putting articles/objects (your Circle objects) inside a container (the cArray), the container(cArray) itself should be allocated space to hold those objects (or as in Java hold references to those objects).

So you will need to allocate memory to your array as follows before you put any values into it:-

int[] cArray = new int[/** Put the size of the Array here **/];

Here is a small concept clearing tutorial on Arrays in Java.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

606

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Newbie or Old geek, announcements exist in the forum for a reason.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Using the showOptionDialog() from the JOptionPane class, you should be able to achieve that. As JOptionPane in the "showOptionDialog()"does allow you to add your own custom components.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Yes that is strange, try setting the "title" in the called URL / web page, to override the address from being displayed in the title bar.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

You do not need that "for" loop.
My suggestion is to just initialize a counter example :-
"lineCounter=0", just before the "while". And in the "while" block just put the following line :-

a[lineCounter++] = strLine;

That should do it.

<EDIT>
Shucks I guess javaAddict beat me to it.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

This should be the first place to start.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Look here for more info on that.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

" The complier keep saying <indentifier> expected."

This seems like a compilation error, although you will not get a stacktrace, the java compiler would definitely have pin pointed where this error was found ???
Also the next time paste your code inside code tags like this :-

[code=java] // Your code here

[/code]

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Well I have another suggestion, if you are opening a new browser window via Javascript why don't you just hide the address bar in the pop up ??

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

If you use frames, then the URL in the address bar would be only of the main page which accommodates all the frames. But getting the URL of the page inside the frame is not too difficult.

Alternatively if you use the <jsp:forward> tag then I **suppose** the address bar would only be displaying the URL of the page from which request was forwarded, but this is only a guess.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

tin sin pin


dream

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

pat cap cut

glued

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

602

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I am not sure then what to initialize my String output to. I am lost.

Ehh !!! Its your program you tell me what you wanted to be printed instead of "null" !!!

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

You need to give some information on your Graphic card ?
If you use Nvidia or ATi, then you will need to install their respective drivers from the livna repository.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Now I could be wrong (because most probably Java has numbed much of my C++ knowledge) but looking at your function :-

bool convertToCString(int& refConstInt, char** ptrtoCharPtr)

It is expecting a reference as its first parameter but you are passing an "int" here.

convertToCString(value, &cstr);
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

First of all what is Echelon form Do you mean this ?
I remember reading about it during my college days but can no longer recollect it.

BTW better learn to indent your code. For now your programs are small, As soon as they cross a few hundred lines you will find yourself spending too much time on just figuring out the closing / opening brace of a block of code, or searching for code blocks of while, if etc.
You can refer here for the Sun Java Coding Conventions. Although you need not read all of it, just take note of the basic parts for ex, code indentations, variable and method naming conventions etc.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I do not know how relevant this is, but in core Java I use the DBPool library which performs database connection pooling for me.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I repeat once again what I had said in the previous thread :-


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

Federer is a better player than Rafa.

:@ :@
Great that shows you know a lot about Tennis !!!! :D

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

If you carefully check the following piece of code :-

String output = null;
String menu = null;
Scanner keyboard = new Scanner (System.in);
System.out.print("\nEnter your taxable income amount: $");
do {
  taxAmount = keyboard.nextInt( );	// Stores the chosen movie.
  validInput = true;
  if ( (taxAmount < 50000) ) {
    System.out.print ("\n(You must an amount greater than or equal to $50,000): $");
    validInput = false;						 
  }
}while(!validInput);
			
// A method call to displayMenu
displayMenu (menu, validEnter, enter, output);
			
// A method to call to computeIncometax
computeIncometax (taxAmount, enter, tax1, tax2, tax3, tax4, tax5, tax6, taxfinal1, taxfinal2, taxfinal, alphatax, betatax);
			
// A method to call to displayFinal
displayFinal (taxAmount, output, taxfinal);

From the start to the end when you call the method displayFinal(). the variable "output" is never initialized (Apart from being initialised to null at declaration time), which is why "null" is getting printed.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Put your code inside code tags, like this:-

[code=java] // Your code here.

[/code]

The rest like the output you are getting, post it as :-

[code]

//Output on compiling / running the program.

[/code]

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

What file is it my friend?? (Ill look in mine and see if mine is there)

I do not know about AOL but if you use Pidgin/Gaim (which is a good chance if you use the GNome desktop environment on ''linux ) and tell it to save passwords, it saves them in plain text in a file called account.xml in your home directory, the same is applicable to its windows version too.
Ever since then I have stopped saving my passwords on it.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Wrap your code inside code tags.

Like this:-

[code=java] // Your code here

[/code]


Here is a tutorial on implementing the ActionListener which you will want to catch your events when your button is clicked.