2,827 Posted Topics
Re: Not entirely sure what you are going for here, but you have a 2-D array and a function that returns a pointer to an integer, so at the very least, you need to dereference that 2D array at least once. [code] return *C; [/code] This will at least compile. | |
Re: So it is outputting correctly to a file, but you want everything that is outputted to the file to also be outputted to the screen? | |
Re: [QUOTE=musique;860509]What is wrong with my sorting function? I am trying to put numbers in ascending numbers. [code] void sort(int array[], int numts) { int lowIndex, lowest; for (int count = 0; count < (numts-1); count++) { lowIndex = count; lowest = array[count]; for (int index = count + 1; index … | |
Re: Seems to me a Snake has several things: 1. Number of segments in its body. 2. (x,y) location of each segment of its body. 3. Direction its head is moving (north, south, east, west) 4. Its velocity (reciprocal of the amount of time it takes for the snake to move … | |
Re: Like this: [code] winningNum[0] = num1; winningNum[1] = num2; winningNum[2] = num3; winningNum[3] = num4; winningNum[4] = num5; winningNum[5] = num6; [/code] | |
Re: One, please format your code. Two, the code will be easier to follow if you pick more descriptive variable names: [code] float calculateGrossPay ( char ps [ ], int input [ ], int size) { float amount; for (int x = 0; x < size; x++) { if (ps[x] == … | |
Re: If you are asking about ways you can improve it, if you look at [URL="http://www.cplusplus.com/reference/clibrary/cstdlib/itoa/"]itoa[/URL], it needs to be able to handle negative numbers and it needs to be able to handle different bases: [code] char * itoa ( int value, char * str, [COLOR="Red"]int base[/COLOR] );[/code] | |
Re: [QUOTE=mhodgkins;859861]Not so much a problem with the code. it compiles and it runs. I have just been looking at it so long I think that I am stuck. It just all jumbles together at this point and it's due at midnight. I dunno. I guess I just need a little … | |
Re: [QUOTE=mightykyle;860151]well im trying to get my shuffler to work but i keep getting one. any ideas? [/QUOTE] You keep getting one? What do you mean? I ran your code and it produces a seemingly random string of numbers when I display the entire array like this: [code] for (int i … | |
Re: How about a boolean variable initialized to false? When a mistake occurs, set it to true and display the error message. If the boolean variable is still false at the end after everything is read in, then that means there were no errors. If that's the case, display a message … | |
Re: It has nothing to do with NetBeans: [code] /** * setLocation() * This method sets initial location of a point in 2D * * @param x,y all doubles * @return array points */ public [COLOR="Red"]double[/COLOR] setLocation( double x, double y) { // Temporary variables that take values from the user … | |
Re: [QUOTE=kkbronner;859448]When I compile and run the program, it doesn't display the correct output listed above. I'm wondering what I'm missing. ... thanks for noticing the end }[/QUOTE] You display an endline after every number so you'll always have a single number on every row. [code] for (int n = 0; … | |
Re: Are you trying to do this? [code] #include <iostream> using namespace std; struct A{ A *pointer; int data; }; struct B{ B *ptr; int data2; }; int main() { A * somePointer = new A(); B * someptr = new B(); somePointer->data = 5; someptr->data2 = 8; somePointer = (A*) … | |
Re: There are a variety of ways to do this. These code snippets may be helpful. [url]http://www.daniweb.com/code/snippet1019.html[/url] [url]http://www.daniweb.com/code/snippet1034.html[/url] In general, use a loop rather than picking the numbers all at once as you do. Start with an empty list/queue/vector/whatever, then generate a number. Check if it's in the list already. If … | |
Re: [QUOTE=itslucky;859465]Dear i think there is no need to send the code... i think u haven't understand what im talking abt. i want to open more then one Chat_windows, but they should work separate... but in my case, the last window will take all the control...[/QUOTE] Count me as another person … | |
Re: [QUOTE=Salem;858857]Ask your "friend" [url]http://www.daniweb.com/forums/thread189664.html[/url][/QUOTE] Or ask your other friend. [url]http://www.daniweb.com/forums/thread189695.html[/url] [url]http://in.answers.yahoo.com/question/index?qid=20090430085318AAdtpHS[/url] | |
Re: [QUOTE=JamesCherrill;859083]OK, I'm obviously going bonkers here, but has something happened to the java code tags? Why doesn't this work in preview mode? [CODE=java] i++; [/CODE][/QUOTE] Looks like a bug. It isn't working correctly for me either and it did a few days ago. | |
Re: [QUOTE=confusedin82;856712]I am trying to use an action listener to fill an array, however I want to fill ONE array from two different sources: ComboBox Selection & JList selection. so I am trying to create an Array that will look similar to this format(each line is representing a different subscript) ComboBoxData … | |
Re: [QUOTE=deepakyadav1830;858181]i want to add the value in map to a float value what should i do?[/QUOTE] Extract the value for a certain key from your map (assuming the object is a float?), then add it the other float? If you want a more precise answer, you are going to have … | |
Re: [QUOTE=cassie_sanford;856679]I am supposed to be working on this problem that stores info in a 2x20 array of characters where the row indicates the month and the column indicates teh day. We have to read in from a file and then create a report that displays for each month and for … | |
Re: Read the file in a character at a time. Throw out any white space, then convert the character to an integer. If you don't know the size ahead of time, you'll have to either make the array bigger than the largest possible number of digits, count the digits ahead of … | |
Re: [QUOTE=kelechi96;855501]What i mean is to take sound from my microphone and turn it into a number[/QUOTE] A number based on what? Frequency? Decibels? Much more detail is needed. | |
Re: Image is abstract. Try using BufferedImage. So you don't want the image on the JButton, right? You want to draw it on the JPanel, right? If so, you can add this to the end of your main statement (note, don't add the JButton and don't resize the frame since the … | |
Re: Is this the total number of test scores for ALL students combined or for EACH student? [code] cout<<"How many test scores are there?"<<endl; cin>> numTests; [/code] And does each student have the same number of test scores or does it vary from student to student? Also, what does SIZE represent … | |
Re: Code tags please. Makes it much easier to read. [noparse] [code] // paste code here [/code] [/noparse] or [noparse] [code=JAVA] // paste code here [/code] [/noparse] Figure out where you want to pause, then use a [URL="http://java.sun.com/javase/6/docs/api/java/util/Scanner.html"]Scanner[/URL] object to read in input from the user, which forces the program to … | |
Re: [QUOTE=Seamus McCarthy;856379]I'm trying to install java on my home laptop and it isn't working, i followed all the steps outlined by my lecturer but the javac filename isn't executing properly. Is it setup right by me?? In environmental variables PATH = C:\jre1.6.0_07\bin;C:\Program Files\PC Connectivity Solution\;C:\watcom-1.3\binnt;C:\watcom-1.3\binw;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Metrowerks\CodeWarrior\Bin;C:\Program Files\Metrowerks\CodeWarrior\Other Metrowerks Tools\Command Line … | |
Re: [QUOTE=Freezeskier;855556]thats really all i need, iv written out the code to solve the problem mathmatically however the part im stuck on now is that I cant seem to figure out how to import the data from the file[/QUOTE] It will depend on how the file is organized. You'll need to … | |
Re: [QUOTE=SallyJ;855619]Hi I'm new to C++ and need help urgently. I need a C++ program that converts letters into ASCII numbers. For example if I enter a name James Bond the output would be 66 and 74 Thanks SallyJ[/QUOTE] Typecast the char to an int: [code] #include <iostream> using namespace std; … | |
Re: How about writing a function like this? [code] bool ContainsEachDigitOnce (int num1, int num2, int num3) // returns true if each digit shows up once and exactly once // in the three numbers, false otherwise. [/code] Let the computer do the checking for you instead of you doing it. It's … | |
Re: MySurvey extends JFrame. You have CenterPanel and ResponsePanel extending MySurvey. Therefore they are extending JFrame. If they are panels that you are adding to a JFrame, these classes should extend JPanel, not MySurvey. | |
Re: Yes, I think it is deceptively simple and you are overthinking it. Wouldn't the total for each person be this? [code] moOneAmt + moTwoAmt + moThreeAmt[/code] Thus couldn't you just add this line to your other cout lines (see red)? [code] std::cout << fName << "\t" << lName << "\t" … | |
Re: Read the links above. Use code tags like this: [noparse] [code=JAVA] // paste code here [/code] [/noparse] Here is your program in code tags. The code tags help a little, but the code is still unreadable since it's not formatted/indented. [code=JAVA] public class PurseTester { public static void main(String[] args) … | |
Re: Is the question how to read in all of the sets or how to do something with them once they are read in? If the question is how to read everything from the file, what calls this function? It appears that this function will only read in a single set. … | |
Re: [QUOTE=aunahal2;853307]Hi, I have been spending several weeks figuring this out but couldn`t find way to it. Here is what I am planning to do, I have a text file with several data in it, and I have to extract part of the data into a 2 dimensional array. Here is … | |
Re: [QUOTE=PierreB;853143]New to daniweb. How do I find a card game written in java @ daniweb? Thanks in advance[/QUOTE] Try the search engine. | |
Re: [code] //This is supposed to be the loop that simmulates cointosses int coinflip(int numtimes) { for (int i = 0; i < numtimes; i ++ ) { int numofheads ; numofheads = numofheads + onetesthead(); cout << "test loop"; cout << endl; [COLOR="Red"]return numofheads;[/COLOR] } } [/code] The line in … | |
Re: [QUOTE=pyscho;850557]can someone plz help prog that allows the user to accept 2 end points (using mouse) and draws a rectangle between 2 points (using AWT Frame class and mouse listeners) 2.accepting two strings as comand line argumnts and append both. 3.a prog for accepting string from user. i am a … | |
Re: [QUOTE=group256;849333]thanks again, But I didn't get what you meant in your answer. Could you please give me more details??? Thanks a lot[/QUOTE] I think you may be looking at a segmentation fault here: [code] int **PointerArray; PointerArray = new int* [HEIGHT]; for (int cnt = HEIGHT; cnt > 0; cnt--) … | |
Re: [code] public void paintCom[COLOR="Red"]p[/COLOR]onent( Graphics g) { super.paintComponent (g); for ( int count = 0; count < rectangle.length; count++) { //This is the area where i need help [COLOR="Red"] rectangle[count].draw (g);[/COLOR] } } [/code] See red above. Note the spelling mistake. Try the above and see if it works. | |
Re: [QUOTE=sammyk;849643]Hello everyone, I really need some help with this project I am working on. So I need to go through a text file to search for a particular string (say something like 'play') and then if that word exists in a line I need to find a string after that … | |
Re: Are you talking about the code itself or the clue that a poster is going to be a nightmare to help? In either case, aside from what you mention, a lack of commenting is a good clue. I'm glad you mentioned the variable names. Well defined methods and variable names … | |
Re: [QUOTE=chaos2005;848896][B]Hello! new prospective mentors[/B] I am very excited about joining this site. I do however have a feeling you guy's will not be saying that after a few thousand posts. (I have so much to learn) I am visually impaired, so I spend allot of time home sick with nothingness........ … | |
Re: There is a PHP forum: [url]http://www.daniweb.com/forums/forum17.html[/url] and a Virus/Worm/Malware forum: [url]http://www.daniweb.com/forums/forum64.html[/url] and a database forum: [url]http://www.daniweb.com/forums/forum16.html[/url] Best bet is probably the Virus/Worm/Malware forum. It seems to be Windows-specific though. Are you using Windows? I know nothing about phpBB. | |
Re: Declare your integer array and an ifstream: [code] int A[333]; ifstream input; [/code] Skip the first 14 lines using [ICODE]getline[/ICODE] to grab the line up to the newline and then do nothing with it. You've now reached the 15th line. Set up a loop and read in the 333 integers: … | |
Re: Finding the roots of a cubic equation isn't trivial. See this wikipedia link and scroll down for a discussion and links to finding roots. [url]http://en.wikipedia.org/wiki/Cubic_equation[/url] I personally think that using Newton's Method's and estimating the roots to a very small tolerance would be a better/easier solution than using the formulas … | |
Re: Try changing this line: [code] if (num2 || denom1 || denom2 == 0) [/code] to this: [code] if (num2 == 0 || denom1 == 0 || denom2 == 0) [/code] | |
Re: You'll need to write the set and get functions for Student and Subject, as well as possibly adding some. Do you have a Subject object in main? I think you'll need one. Start reading in from the input file into variables in [ICODE]main[/ICODE], then use your set functions in the … | |
Re: Anytime you get an "undeclared: first use" error, double-check the spelling. In your case, you have some slight typos: [code] cin>> [COLOR="Red"]dfistnubmer[/COLOR];[/code] instead of: [code] cin>> dfi[COLOR="Red"]r[/COLOR]stnu[COLOR="Red"]mb[/COLOR]er;[/code] You left an 'r' off and transposed "mb": Fix and recompile. Then you have: [code] [COLOR="Red"]cin[/COLOR]<< [COLOR="Red"]([/COLOR]"Please enter the second number that you … | |
Re: Try changing your function call (line 29) to this: [code] dissectCustLine( input, name, addr, telephone, carinfo, payment ); [/code] You want to pass the function a pointer to the START of each array, which is index 0. Right now you are passing pointers to one character PAST THE END of … |
The End.