1,608 Posted Topics
Re: If you can't process the information in Form1 file itself then you might be able to incorporate the information you want extracted by passing a parameter by reference to the buttonclick function (or whatever action function you want to use) if the function has an extra parameter for you to … | |
Re: } infile >> sDat; } Drop this call to >>, only do it in the conditon of the while(). Otherwise only every other piece of data in the file is going to be used in the running totals and calculations. Not every if has to be followed by an else. … | |
Re: Replace this: inStream >> next; while (!inStream.eof()) //while loop not working with this: while (inStream >> next) //while loop working { and do this: outStream.open(outfileName.c_str(), ios::app); //appends to the end of the file each time only once, before the while loop. And drop the inStream >> next in the following: … | |
Re: It depends on what you mean by senior student. If you mean a project for a senior in secondary education who's had one or two courses in C++, then I had some fun recently working through the concept of line sweeping to perform tasks such as finding the two closest … | |
Re: In my experience, debugging of this sort frequently requires that you do a calculation with pencil and paper specifying the value of each variable associated with a desired input. Then generously sprinkle output statements within the program to show the value of the same variables in your program when you … | |
Re: Use a compound conditional like this: if(number >0 && number < 10) | |
Re: Always start with what you know. So I'd start with a simple empty program. Then I'd look up pow() and sqrt(). Finally I'd look up information on output flags and manipulators, particularly those having to do with precision. | |
Re: Separate the .h file into two separate files. The .h file should contain lines 1-22 of current .h file and the remainder should go in a .cpp file, which should have the same name as the .h file, but a different extension. the .cpp file should have the .h file … | |
Re: This:[code] else sum = 0; sum = sum + A[number];}[/code] is equivalent to this:[code] else { sum = 0; } sum = sum + A[number];}[/code] meaning sum is set to zero everytime through the loop and then a junk value, called A[number] is added to it, so it is still … | |
Re: I can see getting the area of union of two rectangles defined by a series of three points. Is that good enough? I can also do it for a series of four points, if there isn't a common vertex. | |
Re: You use two counters in the course of the program. Both are set to zero before the first run of scores, but only one is reset to zero if the user wants to do another set of scores. Fix that and see if your problem goes away. | |
Re: Please provide sample format of AData.xls. Is the general .xls format a comma separated file with each new line in the spead sheet represented by a new line in the file? Is each line of the matrixes/vector located on a new line of the file? If the 3x20 array is … | |
Re: [code]#include<iostream> bool validRadius(double); //function prototype int main() { double radius = -1; while(! validRadius(radius) //function call ) { cout << "Enter radius" << '\n'; cin >> radius; } cout << radius; } //function definition bool validRadius(double r) { bool result; //declare return variable //determine value of return variable if(r < … | |
Re: //algorhithm to read file containing matrix data where size of matrix (which will always be a square matrix) precedes matrix data. There may be data for 1 or more matrixes in the file. [code] int sizeofMatrix, i , j; ifstream fin("myfile.dat"); //check if file open and continue only if it … | |
Re: put the return outside the for loop, otherwise you will exit the loop the first time through every time it's called. Consistent indenting would improve your code even better than the appropriate placement of the return value in computeSum(), however. | |
Re: Whenever you write a function you can ask yourself three questions. What does the function need to do it's job and where does it get the information from? The information necessary may come from information passed to the function, information given to the function by the user through a keyboard … | |
Re: The wording in 4) suggests that you don't need to calculate the winnings on the fly lines 90 and 94. Keep track of the number of guesses and pass that value to a function called calcWinnings() which is called on line 81 . Use the value passed in as the … | |
Re: What problem/error is involved? I'd start out by creating an input that I know the results of. Then I'd either use my debugger to monitor the variables as the code is being processed or put in code to output the value of each variable to the screen as it is … | |
Re: I suspect you could end up with a protocol using one or more nested loops. However, an example of encrypt1, encrypt2, and phrase with expected output would be helpful. | |
Re: If you can't use containers then it is difficult (impossible?) to use loops. You could try an elaborate sequence of if/else similar to the sequence below which sorts the three ints into ascending order without using a container or a loop. To do this for 10 variables would be absolute … | |
Re: [url]http://www.cppreference.com/wiki/io/clear[/url] link to the clear() method of input stream. It's under the C++ I/O link on the main page, then click on clear. This site deserves to be on your list of favorites, if it isn't already. | |
Re: So what's the definition of a "quadratic recursive sequence"? | |
Re: Assuming there are no spaces between the *s on any given line and the font you use has the width of a space equal to the width of a *, then a table of spaces and *s would look like 0 0 10 1 1 9 2 2 8 3 … | |
Re: mcriscolo gave you two pieces of good advice in post #11. You noticed the second, but not the first. Implement the first piece of advice and see what happens. | |
Re: Not bad for a first post! However, you need to start indenting your code. It makes it easier to read and it makes it easier to debug. For example, it appears you are missing a terminting curly brace, which should probably go before this line: empty = totalRoom - totalOcc; … | |
Re: You are using C style strings for the names, which is fine, but you can't compare C style strings using the == operator. You can compare stl string objects using the == operator. To compare C style strings for equality you need to use strcmp() and evaluate the return value. … | |
Re: Take a look at your middle snippet in post #6. In each row there is a series of spaces followed by a series of digits. There is a relationship to the number of spaces and the number of digits and there is a relationship to the type of digits used … | |
Re: No C++ syntax error that I see. The calculations look ok. But you recalculate this value (edgeRadius * edgeRadius *PI) twice, whcih you could avoid. Though that is a very minor nitpick. | |
Re: Use a variable to keep the current min and another varaible to keep the current max. As you encounter a new vaule compare it to both the current min and the current max. If the current value is higher than the current max, it becomes the new max, and if … | |
Re: in main.cpp try changing #include "fifoqueue.cpp" to #include "fifoqueue.h" then recompile and see what happens. | |
Re: remove line 127. In main() you declare an instance of class Month and call it m1. You then call two member functions correctly a few lines later. You could try creating two other instances using your 2 other contructors and output the results if you want. Month m1('J', 'u', 'l'); … | |
Re: I'm not sure of your exact task, nor whether the function prototype is written in stone. Based on my (admittedly limited) understanding of your project I'd break it up into (at least three) separate tasks---searching the list for the names, swap the names if both are found (or stopping if … | |
Re: if dataMember is a string variable encapsulated in the object item, then yes, you could potentially use either node->item.dataMember or node->item->dataMember depending on whether item is on object per se' or a pointer to type. | |
Re: line 24 is junk since ROWS and COLS are not valid indexes for the matrixes. The same for line 32. Try to get this working with hardcoded data before reading in data from a file, so comment out lines 12 through 16, line 24 and line 39. Recompile and run. | |
Re: Answer these questions and you'll be well on your way. How do you access a given element of a 2 dimensional array? What is the range of valid indexes for an array of size n x n? Determine the indexes of the element occupying the first row middle column. If … | |
Re: Forget about writing code for now. Using pencil and paper figure out the relationship between the three classes and attributes of the three classes. Then try to write code. Often, if your paperwork is detailed enough the code is almost written. DON'T use variable names or class names like a, … | |
Re: This is C style output. While legal in C++, usually cout or other output streams are used in C++. The % operator in this situation is a flag telling the compiler/linker that the following letter is a variable type and the letter stands for the variable type. d stands for … | |
Re: look up stringstream. However, note that some floats cannot be completely represented by a stream. Therefore, only a "limited" number of digits will appear in the decimal portion of the string. Consider the float representation of 1/3. I'ts 0.3333... where 3 goes on indefinitely. When converted to a string the … | |
Re: A list is bunch of nodes related to each other by the fact that each node can point to the next node in the list, though there may not be another node to point to, and, indeed, there may not be any nodes at all in the list. The variables … | |
Re: Sometimes Google really does help. I typed "representing space using 4x4 matrix" into the search box and came up with a bunch of interesting sites, if you like math. The best summary I found doing a rapid scan of several sites was: Using a 4 x 4 transformation matrix allows … | |
Re: What type of problem are you having? Do you not understand how to obtain and evaluate the numbers in a and b? Do you not understand how to write the program so it can be done for any given size of the arrays? Something else? | |
Re: cdArray[num_cds].print(out); print() is declared as a member function of the CDCollection class, meaning it should be called using an object of the CDCollection class or be used within the CDCollection class itself without explicit association with a CDCollection object. Unforturnately, in the above line you are trying to call print() … | |
Re: I would say the way to stop a loop is to have a way to break out of the loop built into the loop or have a way for the conditional of the while() to evaluate to false. The return value of cin.get() is an istream reference according to my … | |
Re: >>What about individual characters? Is it possible to get the address of those, What do you mean? Do you want to get the address of a char variable when it's declared as a straightforward, stand alone variable, when it's an element of a char array, when it's an individual char … | |
Re: >>How do I fix this problem? move these two line outside of the for loop. average = (sum/numtest); return (average * test_percent); You only need to do them once. The way you have it you exit the function with the return statement after just one iteration of the loop. >>I'm … | |
Re: As monkey_king points out there is a variety of options. Your question is similar to asking "How do I make cookies?" In order to best answer your question we need more input or make our best guess as to what you need/want/know. Do you know there are multiple types of … | |
Re: >>There is only 1 even prime number i.e 2 So, is there a simple way to determine if a number is even or odd? And, if any factor above 2 is even can the number be prime? This might be a little more optimized:[code] bool isprime(int a) { bool result … | |
Re: Your post is equivalent to the following: My toe hurts. Can you tell me why? Please tell us what is happening that you don't expect to happen. Otherwise your guess as to why my toe hurts will only be as good as my guess as to why you aren't getting … | |
Re: [code]while (vendedor.legajo == 0) ingresar_ventas (); //enter sales[/code] the above loop will only run if vendedor.legajo equals zero. In addition, there is no way to change vendedor.legajo from within ingresar_ventas(), so once ingresar_ventas() returns, vendedor.legajo will still be zero, so away you go again, for ever and ever and ever. … |
The End.