2,827 Posted Topics
Re: Lines 16 - 29 - The indentation here is really bad, so the code is hard to follow. How do you get out of the while loop? | |
Re: Get rid of the for-loop that starts on line 15. There's no need for it. Your do-while loop should be able to handle any exiting. There is no need for a for-loop and what if I want to quit before I enter an option 30 times? If the array of … | |
Re: [QUOTE=NinjaLink;1001512]Is there another way of using it? Please advise.[/QUOTE] Did you bother to even google it at all like firstPerson said? You should have [url]http://www.cplusplus.com[/url] bookmarked, or some very similar site. There are loads of them. Do some research yourself before posting here. Post here when you've done the research … | |
Re: [QUOTE=power_computer;1000826]Even If I load them into one array the two arrays are of different types so elements in the array will vary what kind of array would I load them into ? each different class array contains atleast 4 -5 values in each element perhaps an array of structs? making … | |
Re: Generate 50 numbers in the range of 0 through 51 with no repeats: [url]http://www.daniweb.com/code/snippet217217.html[/url] Add 65 to numbers that are less than 26. Add (97 - 26) to numbers that are 26 or greater. The stick 'em in your Linked List or do whatever you're going to do with them. | |
Re: What's the question? How to set use a virtual function? How to use a derived class? How to write a driver program? The mathematics behind collision detection? How to write the collison detection function? How to call it? Etc. Who wrote the code you posted? | |
Re: [QUOTE=ajeet choudhary;999252]sir according to me u have to push all numbers in a stack and thn using plus opretor pop out these all thn u will get sum of all numbers[/QUOTE] No stack is required to calculate the sum. Set up a sum variable and initialize it to 0. Read … | |
Re: "Seg fault" is a bit vague. Seg fault on what line, with what Linked List, searching for what values? How many nodes in the linked list? Does the key exist in the Linked List? How many elements? Is the key smaller than the smallest element? Larger than the largest? What … | |
Re: From your assignment spec: [LIST=1] [*]Create a new project called 5.06 Monte Carlo Method in the Mod05 Assignments folder. [*]Create a class called BottleCapPrize in the newly created project folder. [*]Determine how many times a die must be rolled in order to win a prize. (This represents one trial.) Print … | |
Re: Well, do you have to do anything with these strings of characters or are you just making sure everything's balanced? If the latter, there's not a lot to it. First, ignore anything that isn't a bracket of some sort. You push any opening bracket you run into. When you hit … | |
Re: [QUOTE=Ancient Dragon;998388]I have noticed on some boards (e.g. [url]http://www.dreamincode.net/forums/showforum15.htm[/url]) that when I post two consecutive posts the forum software will merge them into a single post. Is something like that possible to do here at DaniWeb ? Of course it would have to be pretty low on the TODO list.[/QUOTE] … | |
Re: [QUOTE=truviet911;998150]don't expect to see this kind of response. if you want u can just banned me permanently from this forum.[/QUOTE] What response did you expect to see? This is pretty much the response you're going to get from everyone on just about any forum. This is the thread Lerner refers … | |
Re: [QUOTE=poojasweetgirl;997888]i have to print this ******** *** *** ** ** * * ** ** *** *** ******** my code is [code=JAVA] class one { public static void main(String args[]) { String s1="*";int i,j; for(i=4;i>0;i--) { for(j=0;j<i;j++) { System.out.print(s1); } for(int k=0;k<8;k=k+2) { for(int m=0;m<k;m++) System.out.print(" "); } for(int n=4;n>0;i--) { … | |
Re: This program doesn't compile for me due to errors like this in line 19: [quote] invalid initialization of non-const reference of type 'std::string&' from a temporary of type 'std::string' [/quote] You're saying you were able to compile and run this? | |
Re: [QUOTE=gibson.nathan;997455]from your first reply, i think this may have been what you meant, did this fix the counter problem?[CODE]for(int side1 = 0; counterTrials <= numberOfRolls; counterTrials++) [/CODE][/QUOTE] That's better. The whole program can be redesigned significantly. One, use arrays. Two, [quote] i have to display the probability of each side … | |
Re: [QUOTE=Der_sed;996403]The file "airports.csv" contains [U]12 pieces [/U]of info per line - separated by commas: [B]BIN,"Bamiyan","Bamiyan","Afghanistan","AF",34.800000,67.816667,701,"Afghanistan",\N,\N,1149361[/B] (there are 3 such lines for now) How do I modify my program to take the 1st, 3rd, 5th,6th,7th pieces of info per line and store them in an array- ill later use that array … | |
Re: If S is a 2-D array, it should have a type of unsigned int **, not unsgned int *. If it was a 3-D array it would be unsigned int***. A 4-D array would be unsigned int****. You have to do the "new"command in stages. This won't work: [code] unsigned … | |
Re: Yes, character arrays can be a bit tricky, and passing and returning arrays can be tricky. There is more than one way to do what you are doing. This way does not use dynamic memory. I'm not sure if you are trying to use dynamic memory or not. Here's a … | |
Re: [QUOTE=NinjaLink;994439] I am currently having problems and need help with: [B]1)[/B] Printing the words in reverse order in my printList function [B]2)[/B] Printing the words in alphabetical order in my printList function [/QUOTE] You need a sort function to put something in alphabetical order. printList should do that: print the … | |
Re: [QUOTE=tksrules;995270]How to move pointer in display to beginning of line.I don't want to create a new line.I want to take the cursor/pointer to the beginning in same line. [/QUOTE] I don't believe this is "minor" at all. I certainly have never done it. Googling "java gotoxy" yields some good results, … | |
Re: [QUOTE=marlinssmith;995826]Hi, I am trying to write a program that finds the minimun and maximum number in an input set of numbers. I am using a loop to update the set as the program reads the cin. Example code: [CODE]min = max = -1 cout << "Enter termination value that will … | |
Re: Regarding the 'y' or 'Y' or "n' or 'N' test, don't confuse the | operator with the || operator in your if statement. You want the || operator. Regarding the left justification, you have included iomanip, but you haven't used it. iomanip will help with setting the column widths and … | |
Re: You have two separate problems. Approach them separately and independently: [LIST=1] [*]Get good input from user. [*]Draw rectangle based on that input. [/LIST] Part 1 - You must ask the user for input. You must check that input to see if it meets your requirements. If not, you should tell … | |
Re: Your program doesn't compile. Look at your while loops. Here's a template: [code] for (/* variable initialization*/; /* check condition */; /* variable adjustment */) { // code to repeat } /* variable initialization */ while (/* check condition */) { // code to repeat. /* variable adjustment */ } … | |
Re: How many nodes do you want to delete? Line 19 deletes a node every time it goes through the for-loop. If you only want to delete one node, don't stick "delete" in a loop. | |
Re: [QUOTE=NT.;994634]Hi, I am trying to divide array elements in low and high using a single for loop. But, I don't know why I am getting ArrayIndexOutOfBoundsException. I tried working it out on paper and it seems correct. Can anyone point out my mistake? Thanks!! [CODE] for(int i=0;i<=n/2;i++) { ALow[i]=A[i]; AHigh[i]=A[i+n/2]; … | |
Re: [QUOTE=hsheen;994814]hi everyone, i'm not on a expert level of java language. however if anyone can help provide a sample code on how to create a simple java game either using java standard edition or micro edition is highly appreciated. thanks.[/QUOTE] One, no one here gives away code. You post the … | |
Re: There are a few ways of doing this. First, do you have an allowable range that the input must be in (say 0 to 9)? If so, you can set up an array to keep track of the number of occurences: [code] int occurences[10]; // initialize all elements to 0. … | |
Re: You should specify a type for the ArrayList in functions like this: [code] public static void SavePlayer (Scanner input, ArrayList playerArrayList[B])[/B][/code] Change to: [code] public static void SavePlayer (Scanner input, ArrayList [COLOR="Red"]<Player>[/COLOR] playerArrayList)[/code] | |
Re: You can return a pointer, but you cannot return an array. You can also pass the array to the function and have the function fill it in: [code] void diceThrow (int array[], int numRolls) { // fill in array with random dice rolls } int main () { int diceRolls[10]; … | |
Re: Lines 9, 13, 17 - These functions are not void. They must return something. Line 21 - I assume that TestComplex is not intended to be an inner class. If not, you need a bracket to end the Complex class on line 20. Lines 26, 34 - Check your spelling. … | |
Re: [QUOTE=paulthom12345;988608]Yeah! Thats exactly it, as we are already in the C++ forum we know the posts are C++ related so we dont need that word clogging up the tag cloud. I dont know, is anyone else finding it irritating? I just find i cant tell what is popular because that … | |
Re: [QUOTE=axelle.eichner;992263]Hey, I'm a student wanting help on how to write a program in netbeans.. I have no idea how to work this website so this question may be in the wrong place but.. here goes: so i need to write a program that outputs a quote one letter at a … | |
Re: NetBeans must be hung up then. Quit it and restart it. If you have more than one class in a project that has a main funtion, you need to specify which main to use. Do this by going into the project's properties under the "Run" category. Next to "Main Class", … | |
Re: Do not use getline here. The first name can be UP TO 30 characters, but will usually be less than that. Your getline stores other fields in the first name. This input file is separated by spaces and newlines, so it is tailor made for the >> operator instead of … | |
Re: The noparse tag solves the problem of having to do these workarounds by adding a space so it won't parse as Java code. [noparse] [noparse] [code=JAVA] // code here [/code] [/noparse] [/noparse] Now if it would only revert back to the old days and stop automatically parsing [noparse][code][/code] as [code=JAVA][/code][/noparse], … | |
Re: The above code should be in a file called "Amicable.java". To compile, type "javac Amicable.java". This should create a file called "Amicable.class". To run it, type "java Amicable". Is that what you are doing? | |
Re: [QUOTE=julia2009;992941]Hy there, I'm a newbie so be patient pls. I have a small but useful class (let's call it Class1), and another class, more complex (let's call it Class2). I need to use in the Class2 instances of the Class1. I need to declare objects of Class1 both in private … | |
Re: [QUOTE=KirkPatrick;993356]Its been awhile since I have toyed around with java, so I'm a bit rusty. But decided to mess with it today. I have a jPanel that I will be adding objects to, but I want to add the in a new row each time a button is clicked. Anyways … | |
Re: [QUOTE=Xamas;990867]I need to build a program - hotel, which has from 1 to XXX rooms. It is ok, when I have only the: [CODE=JAVA]private static int[] array_of_rooms; <... CLASS CONSTRUCTOR ...> array_of_rooms = new int[size]; // Size is defined size, of rooms in the hotel. // Fill default room status … | |
Re: It shows up correctly for me without having to click anything. Often, if you need to click, move, resize, or maximize/minimize something for it to show up, you can solve it by using the validate () from the Container class. [url]http://java.sun.com/javase/6/docs/api/java/awt/Container.html#validate([/url]) But again, I did not have to do this. … | |
Re: [QUOTE=Rofljosh;992205]Yeah, I basically thought that, I suppose most of my confusion has derived from the way the instructions are worded in the instructions are worded. They say this: "...add a constructor that takes two parameters: a string representing a month and an integer in the range of 0 to 31 … | |
Re: [QUOTE=tomtetlaw;991879][CoDE=C++]struct{ int health; int armor; char* wep_name; char* name; } test_player = { 100, 10, "master sword", "tom" }; test_player.health = 1; [/CODE] thisis ym code[/QUOTE] OK, that's your code, but WHERE is it? If line 12 is not inside of a function, you have problems. If it's before main, … | |
![]() | Re: [QUOTE=packmule;991858]Hi, I am just trying to figure out how to access some data. Currently it is stored in a spread sheet in the following form........ [CODE] 8/11/09 9/12/09 .... mm/dd/yy name score score .... score name2 score score .... score [/CODE] there will be many names (and more may be … |
Re: Code tags please. Code is much more readable with code tags. Don't confuse the = operator with the == operator. = is the assignment operator. == is the comparison operator. Don't confuse the two. Here's an example (lines 1 and 3) of their proper use. int a = 5; // … | |
I have a data file that, if I was using C++, I would use the getline function to read its data into the proper variables. However, the getline functions that C++ allows appear to not be available to me in C. I want to be able to specify a stream, … | |
Re: Well, you know ahead of time that for a 6 letter word, you have 2^6 = 64 possibilities. You could have the function return an array of Strings. Have a loop that goes from 0 to 63 (or 127, 255, etc.). For your example, "cat", it would be 0 to … | |
Re: One, code tags and formatting. [noparse] [code=JAVA] // paste code here [/code] [/noparse] Repost using them, please. Code looks terrible without them. Two, you've posted the Stock class three or four times. Why? Three, you need to ask a more detailed question. What error do you get? Compile or run-time? … | |
Re: [QUOTE=power_computer;984496]Ok I have to make a 3-D array within a class and read from a file with input like this [code] 90312 Thing_1 12.34 100 25 // Shelf 9, row 3, bin 12 20705 Thing_2 54.78 24 25 10101 Another_Thing 123.45 183 4 [/code] There array is based off 9 … | |
Re: There's no ending bracket to your function, so is there more to the function? I see no change in the maze[][] array and no other variables that keep track of where you've been. You have cout statements that display an 'X', but what's the point of this? I get a … |
The End.