1,608 Posted Topics

Member Avatar for Djanvk

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 …

Member Avatar for Lerner
0
87
Member Avatar for biggulps

} 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. …

Member Avatar for biggulps
0
122
Member Avatar for kotkata

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: …

Member Avatar for ddanbe
0
116
Member Avatar for Kevinle

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 …

Member Avatar for Lerner
0
92
Member Avatar for kyserthehun

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 …

Member Avatar for ddanbe
0
788
Member Avatar for mercedesbenz
Member Avatar for kalou

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.

Member Avatar for William Hemsworth
0
87
Member Avatar for NinjaLink

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 …

Member Avatar for ddanbe
0
97
Member Avatar for cicigirl04

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 …

Member Avatar for DaJoker
0
283
Member Avatar for gregorynoob

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.

Member Avatar for Lerner
0
185
Member Avatar for Daria Shmaria

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.

Member Avatar for Daria Shmaria
0
7K
Member Avatar for salman1354

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 …

Member Avatar for Lerner
0
87
Member Avatar for LADY187

[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 < …

Member Avatar for LADY187
0
107
Member Avatar for begyu

//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 …

Member Avatar for Lerner
0
276
Member Avatar for cicigirl04

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.

Member Avatar for sidatra79
0
130
Member Avatar for afg_91320

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 …

Member Avatar for Lerner
0
199
Member Avatar for FtKShadow

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 …

Member Avatar for FtKShadow
0
160
Member Avatar for Aric69

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 …

Member Avatar for Lerner
0
160
Member Avatar for Trekker182

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.

Member Avatar for Trekker182
0
137
Member Avatar for wqzerboom

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 …

Member Avatar for rhoit
0
187
Member Avatar for LordoftheFly

[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.

Member Avatar for LordoftheFly
1
308
Member Avatar for defychaos
Member Avatar for Lerner
0
343
Member Avatar for kurorokhristoff

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 …

Member Avatar for Lerner
0
2K
Member Avatar for n8thatsme

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.

Member Avatar for n8thatsme
0
202
Member Avatar for sleepytoast

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; …

Member Avatar for sleepytoast
0
102
Member Avatar for unk45

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. …

Member Avatar for stilllearning
0
232
Member Avatar for Talli

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 …

Member Avatar for Talli
0
131
Member Avatar for Se7Olutionyg

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.

Member Avatar for Lerner
0
254
Member Avatar for MylesDBaker

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 …

Member Avatar for MylesDBaker
0
179
Member Avatar for tones1986
Member Avatar for mehtaneha84

in main.cpp try changing #include "fifoqueue.cpp" to #include "fifoqueue.h" then recompile and see what happens.

Member Avatar for Sci@phy
0
181
Member Avatar for Bigboy06

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'); …

Member Avatar for ArkM
0
337
Member Avatar for nizbit

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 …

Member Avatar for Lerner
0
89
Member Avatar for nizbit

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.

Member Avatar for nizbit
0
182
Member Avatar for NinjaLink

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.

Member Avatar for Lerner
0
110
Member Avatar for unk45

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 …

Member Avatar for Salem
0
693
Member Avatar for charusood

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, …

Member Avatar for Lerner
0
284
Member Avatar for Natrax

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 …

Member Avatar for Natrax
0
76
Member Avatar for Majestics

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 …

Member Avatar for stilllearning
0
2K
Member Avatar for DaveCachia

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 …

Member Avatar for Lerner
0
106
Member Avatar for cam875

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 …

Member Avatar for Lerner
0
69
Member Avatar for gregorynoob

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?

Member Avatar for gregorynoob
0
86
Member Avatar for nizbit

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() …

Member Avatar for Lerner
0
241
Member Avatar for john88

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 …

Member Avatar for MelechM
0
123
Member Avatar for amt_muk

>>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 …

Member Avatar for amt_muk
0
6K
Member Avatar for NinjaLink

>>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 …

Member Avatar for NinjaLink
0
274
Member Avatar for inkcoder

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 …

Member Avatar for Lerner
0
118
Member Avatar for vidit_X

>>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 …

Member Avatar for vidit_X
0
656
Member Avatar for dexter1984

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 …

Member Avatar for Salem
0
101
Member Avatar for gispe

[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. …

Member Avatar for Salem
0
171

The End.