201 Posted Topics
Re: In order to take a random number from the deck, you need to generate a random number that will be the cell of the array - deck[random cell] equals to a random card taken. Note that you need to know which cards have been already taken in order not to … | |
Re: You sure that you put newImage.JPG in the proper directory? the second option is for relative path, you need to be sure that the relative path is correct. | |
![]() | Re: How about you start and we will help? |
Re: Sounds like a perfect job for Google - give it a go right [URL="http://tinyurl.com/27hxrog"]here[/URL]. | |
Re: Ok, few problems that I can see: [LIST] [*]In line 16 you are creating an array [ICODE]int[] gradeArray = new int[sgrades];[/ICODE] when you didn't initialize sgrades - you need to retrieve the number of students in the class, which is the first line in the file. [*]In the loop in … | |
Re: naief, perhaps your intention was good, but the purpose of the forum is to help and guide people toward the solution - just giving the answer is not the proper way to go. Writing bits of code and by that help in places of struggle is always welcome - but … | |
Re: Accessing the first element of row i: [ICODE]arr[i][0];[/ICODE] Accessing the last element of row i: [ICODE]arr[i][arr[i].length - 1];[/ICODE] From here you just need to do the adding :) Give it a go, try to implement it. | |
Re: [URL="http://lmgtfy.com/?q=recent+projects+based+on+networking+or+web"]Google[/URL] it. | |
Re: Congrats, you have code. Do you have a question that comes with this code? Also, please use the code-tags when posting code. | |
Re: Assuming that the code is [CODE=java]for i = 1 to 2 * n { j = i + 1 while j >= 1 { j = j – 1 } }[/CODE] Then let's analyze the complexity: The outer loop is simple, it goes from 1 to 2n, meaning 2n iterations. … | |
Re: As jon.kiparsky said - if you want to show the user output you need to use the [ICODE]System.out.println()[/ICODE] method as you have used in your code in other places. You need to show the families with low income - use the [ICODE]System.out.println()[/ICODE] method in the if clause. Inside the if … | |
Re: First, notice that you are handling objects, which are by reference. The code [CODE=java]PersonNode temp = current;[/CODE] Means that temp points to the location in the heap of current - changes that you are making for current will also affect temp! You will have to copy the object using a … | |
Re: You didn't finish implementing all the methods yet, how do you expect it to work? | |
Re: Integer.parseInt will throw an exception that you will have to catch - not a good practice. | |
Re: [CODE=c]a=a+b; b=a-b; a=a-b;[/CODE] Will indeed swap to variables without a temp. Notice that you have to make sure that a+b does not exceed the maximum allowed integer. There is another way of swapping the variables without these constraints: [CODE=c]void swap (int *x, int *y) { if (x != y) { … | |
Re: Problems that I can see here, first in the code in line 38: [CODE=java]if(Character.isLetter(j)) { p1array = phrase2.charAt(j).toCharArray(); }[/CODE] [ICODE]phrase2.charAt(j)[/ICODE] results in a char, and there is no such thing as [ICODE]toCharArray()[/ICODE] on char. The exact same problem occur in the if on line 49. Second problem is in the … | |
Re: jon.kiparsky's approach of using a class member is the one that I would have used. There is another choice - in case you insist not to have class members, you can have your method return the String back to the main method, and from there you can send it to … | |
Re: It states that you don't have a main method, meaning no method in the format: [CODE=java]public static void main(String args[]) { // something here }[/CODE] This is the method that is called first, and when it ends the program ends as well. | |
Re: It's called Generics, and I think that [URL="http://en.wikipedia.org/wiki/Generics_in_Java"]this[/URL] will give you some sense into it :) | |
Re: Take a look at [URL="http://www.daniweb.com/forums/post628847.html#post628847"]this[/URL] thread. | |
Re: Let's take a look at [ICODE]makeFirstReservation[/ICODE] method: [CODE=java]public static void makeFirstReservation(int[][] totalSeats, Scanner input) { for (int row = 0; row < 3; row++) { for (int col = 0; col < 4; col++) { row = input.nextInt(); col = input.nextInt(); System.out.println(totalSeats[row][col]); } } }[/CODE] Every iteration of the inner … | |
Re: You need to replace the %d with %f to print float numbers. [CODE=java]System.out.printf("%f\t\t%.1f\n",t, distance); [/CODE] | |
Re: I don't see any question. What exactly is the problem? | |
Re: Have you tried [URL="http://tinyurl.com/27eymzt"]here[/URL]? | |
Re: You Bookcase array should be an ArrayList of books. Each cell in the array will contain a Book. Right now your book case just contains more book cases inside, instead of books. [CODE=java]public class Bookcase { public ArrayList<Book> mybooks=new ArrayList<Book>(); public Bookcase(String title, String author, String publisher, String isbn) { … | |
Re: You can always implement copy constructors in your class: [CODE=java]public Class yourClass { public yourClass(yourClass yourClassObject) { //implement } }[/CODE] Other than that, you need to read the API about mutable and immutable objects to help you decide how to implement their copy in the constructor. | |
Re: How about [URL="http://www.daniweb.com/forums/thread573.html"]showing some effort[/URL] first? | |
Re: Explain the problem and your approach, don't expect everyone to guess what you need to do and code it for you. | |
Re: Please use the code-tags when posting code. A String array is declared String[] purse = new String[the size of the array] So if you want the variable purse to be an array of size 100 the code will be: String[] purse = new String[100] Regarding the method `addCoin(String coin)` - … | |
Re: After you have read the tutorials kremerd gave you, we will gladly help you. Just show us [I]your[/I] code, and where exactly you are stuck. | |
Re: Or in simple words - please show some effort, and we will do our best to help and guide you :) | |
Re: [LIST=1] [*]When you insert the values to the arrays, keep a counter - this way you will know what was the last cell that you have written to - at the end instead of [ICODE]RMSD_Final = R2 / coordinatesRotZ.length;[/ICODE] just do [ICODE]RMSD_Final = R2 / counter;[/ICODE] [*]The loop in line … | |
Re: The recursion is checking all the possible permutations of the sources[] array. If you were given the task to write all the permutations, one approach would be to just: [LIST=1][*]Fix the number of the first letter. [*]See all the permutations of the n-1 letters remaining.[/LIST] To see the permutation of … | |
Re: This thread is more than 5 years old, the OP had probably finished his PhD by now. Please open a new thread and leave old threads to die in peace. | |
Re: You then can use peter_budo's method like this: [CODE=java]int[] varArr = getNumbers();[/CODE] | |
Re: Ok, I will help you with part of your research and will direct you to the [URL="http://download.oracle.com/javase/6/docs/api/"]Java 6 API[/URL], specifically to the [URL="http://download.oracle.com/javase/6/docs/api/java/util/Random.html"]java.util.Random[/URL] class. This should help you with the creation of the Random numbers. After creating the random numbers, think how you make sure that the number generated is … | |
Re: In your main method when you call [CODE=java]Rfc rfc =new Rfc(ip,80);[/CODE] You mean the ip you have declared inside the method but it is not reachable since it is inside the try code block - move all of the code inside the try block. | |
Re: Then the least you can do is to mark this one as solved. | |
Re: After you have finished adding all the contacts, then convert it into array, outside the loop is the right place :) EDIT: masijade beat me to it while I was typing :) | |
Re: In your [ICODE]get_hours[/ICODE] and [ICODE]get_payrate[/ICODE], you are creating a new variable and sending it back. First, as kremerd said, you don't need to do that, since your intention is to return the global variable[ICODE] _hours[/ICODE]/[ICODE]_payrate[/ICODE] that you have already declared and initialized. What happens is called [I]Shadowing Declarations[/I], you can … | |
Re: Well, the problem is because those are two different T's :) One is the class T, and the other one is the insert method's T. Let me explain - when you used the syntax [CODE=java]public <T> void insert(T item)[/CODE] You actually declared a generic method that uses the parameter T … | |
Re: I remember that I tried to search for a solution but eventually excepted the warnings, and ignored them :) I understand how annoying those warnings can be, but if the code ensures that the types are the same, I don't think you should break your head to much around it. | |
Re: This is like assigning a number to a char variable - it will interpret it as the ASCII value. As kremerd said - you need to convert them into a String. | |
Re: Two extremely common questions are: Given a binary tree, reverse it, such that for every node x, swap x.leftChild and x.rightChild - analyse the complexity of your solution. Another one is similar - given a singly linked list, reverse the list. Analyse your complexity. A non-programming question - you are … | |
Re: First of all, I think you better use the [Random](http://download.oracle.com/javase/6/docs/api/java/util/Random.html) class rather the `Math.random()`. If you want the game to continue until a certain condition is true, you can use the while loop: while(expression) { //do something } As long as the expression is true, the loop will continue. In … | |
Re: Take a look here: [url]http://www.leda-tutorial.org/en/official/ch02s02s03.html[/url] | |
Re: First, excellent post - every experienced programmer is doing all of above and more after learning it the hard way - you cannot force your brain to work and solve all your problems, sometimes you need to rest, sometimes you need a different approach, and almost all of the time … | |
Re: What have you done so far? Which part of the code you already have, and which part do you have trouble with? | |
Re: Since you are retrieving the HTML code, you can parse the <a href = "HTML SITE> </a> tags in order to get the hyperlinks. What exactly do you mean by "parsing all the visible text from the particular web page"? | |
The End.