1,608 Posted Topics

Member Avatar for mariel_1013

in inputData NUM_MONTHS is not a valid index for sales[]. in highMonth and lowMonth why assing i to highest and lowest right after you assign sales[i] to it. There may be other concerns, but that should be a good start.

Member Avatar for mariel_1013
0
313
Member Avatar for enkitosh

There is a game development forum on this site. I don't go there much so I don't know if people who do routinely spend a fair amount of time here, or not. I also expect you could get some idea of the way other people do it by doing a …

Member Avatar for Serapth
0
362
Member Avatar for Nathaniel10

put lines 44-54 in a while loop and use whatever technique you're comfortable with keeping it going/stopping when you want to.

Member Avatar for Nathaniel10
0
122
Member Avatar for sergent

use a pencil and paper to write out the values in the vector after each insertion into the original vector in the example you've posted. Remember it is myvector.begin() and not another vector.begin(). it + 2 means start two positions beyond myvector.begin(), which would be position 3 of myvector. don't …

Member Avatar for sergent
0
440
Member Avatar for jojodeco

Move line 34 to between line 36 and 37. This brings the output statement to the end of the inner for loop but still in the outer for loop. Reset heads and tails to zero each time before starting through outer loop.

Member Avatar for Lerner
0
177
Member Avatar for sandyneedshelp

This appears to be a combinatorial or permutation type problem. Except for CDA it looks like all combinations read from left to right of shorter length than the lhs of = sign. However, your intention isn't clear to me. Please try to explain your plan in further/better detail.

Member Avatar for sandyneedshelp
0
167
Member Avatar for blueyan
Member Avatar for jojodeco

There is probably a mathematical way to account for the 56% probability, but you could also hard code it. To hard code it you could create and array of 100 ints all assigned to 0s. Then place 44 randomly placed 1s in the array. Then for each turn, get a …

Member Avatar for Eagletalon
0
569
Member Avatar for phorce

You have 3 for loops that are nested one within the other, 2 of which use i as the variable. Don't duplicate the variable name if you have a 3 deep nested loop or, as in your case, don't use a 3 deep nested loop. OffsetX doesn't really double each …

Member Avatar for phorce
0
118
Member Avatar for poolet

The row and colum labels can be dealt with separately from the game board itself. You can't assign a whole row at a time because the board is an array of type int, not an array of strings. You will need to give each cell of the board a value …

Member Avatar for poolet
0
143
Member Avatar for itsanicole

while (column < 10) column ++; { cout << row * column << "\t"; } should be while (column < 10) { column ++; cout << row * column << "\t"; }

Member Avatar for Lerner
0
389
Member Avatar for caltech

Ok. So I haven't downloaded and compiled your program or anything like tha, but here's what I think is going on. First the file has five data fields per line: last name, first name, hours worked, pay rate and age. The records class has 7 member values. So when you …

Member Avatar for Lerner
0
2K
Member Avatar for Hilfiger

Very vague instructions in the posted link. The best thing to do is to try to get better description of the problem. Alternatively, you could conceivably consider declaring a document class which has member variables such as author, date of creation, date of edit, or whatever. Then you can declare …

Member Avatar for Lerner
0
115
Member Avatar for initialfresh

>>>it outputs and waits for the input on a new line...how can i make it wait for input on the same line? Try not putting endl or newline char at end of the cout statement. If that doesn't do it, then indicate where in the code the problem is found.

Member Avatar for Lerner
0
203
Member Avatar for jaclynkinsey

It doesn't look like it's a problem with your use of the return value of eof() that's the problem. If you're going to use eof() to control the while loop that's the way to do it. The problem looks like it's the use of two input methods in the same …

Member Avatar for jaclynkinsey
0
169
Member Avatar for justanoob

To write a game like this one could consider use of loops, arrays, menus, switch statements, generation of random numbers and classes/structs. These are basic tools to creating a program, but depending where you are in your educational process you may or may not be familiar with some or all …

Member Avatar for Lerner
0
197
Member Avatar for jumo1807

Since you don't change the value of number in the functions number is sent to is there a reason you send it by reference instead of by value? If you are going to return true/false, then have the return type be bool. >>catch the values 2 and 3? Sorry I …

Member Avatar for Lerner
0
135
Member Avatar for RonKevin

Put the word code enclosed in square brackets before the first line of code you post to this board and the word code preceeded by a backslash enclosed in square brackets after the last line of code you post to this board. This will preserve the indentation you (hopefully) use …

Member Avatar for RonKevin
0
135
Member Avatar for Griff0527

Typically (though not always, I suppose) you would declare a variable of type romanType in main and call the member functions you want use on that variable:[code] main() { romanType myRT; myRT.romanToDecimal(); myRT.decimalToRoman(); }[/code]

Member Avatar for raptr_dflo
0
377
Member Avatar for Johnathon332

[code]struct StringArray { char sArray[10][10]; void setString(char *s, int pos) {strcpy(sArray[pos], s);} };[/code] setString should change/set/mutate sArray by assigning s to element pos in sArray. You need to use strcpy() to "assign" one C style string to another. You would need to be sure there is enough room in sArray[pos] …

Member Avatar for mike_2000_17
0
684
Member Avatar for Kitson

filename has been declared using type string. stream objects need null terminated strings to associate with a file, so you need to adjust the filename by calling the c_str() method in order to open the file. using the return value of eof() can lead to bug. If you don't try …

Member Avatar for WaltP
0
848
Member Avatar for FraidaL

Use pencil and paper. Start with 3x^2 - 4x + 1 Rewrite this as: 3x^2 + (-4)x^1 + 1x^0 If I remember correctly the first derivative is 6x - 4 and the second derivative is 6 The general protocol to determine the value of any given term in the next …

Member Avatar for Lerner
0
3K
Member Avatar for tamana

Version 1: set variable to hold largest value to be value of first element in the array. Check each element in the array from index 1 to less than total number of elements in the array. If current element is the larger than currently recorded largest value, assign current value …

Member Avatar for Lerner
0
419
Member Avatar for Shaye12321

Without seeing the declaration of cmptchoice it is a little speculative as to what your problem is. Having said that, you can't output an array with a single call to <<. You will either have to output each element in cmptchoice individually or you will need to change cmptchoice from …

Member Avatar for Shaye12321
0
1K
Member Avatar for ShEeRMiLiTaNt

How do you tell when you've come to the end of one word and the start of the next when looking at a sequence of characters? Be consisent. If punctuation is considered part of a word in one setting, then it always is. World ! you? is not consistent when …

Member Avatar for Lerner
0
913
Member Avatar for tj104

You can always read data in as a string. If the input is numerical in value, then convert the sring to a numerical type. If not, then the only non numerical string in your file tells you to stop input into the current polynomial.

Member Avatar for Lerner
0
148
Member Avatar for alanso

For future reference please enclose any code posted to this forum in code tags. The directions on how to do so are posted several places throught the board. Second, please ask a specific question. It's unlikely that anyone with run your code to get their own error messages and try …

Member Avatar for Lerner
0
112
Member Avatar for Programmer!!!

To compare C style strings you would use strcmp(), or a related function, rather than the < or the > or the == operator like you would for numerical values. If you are alllowed to use STL string objects, then the STL string class has the <, > and == …

Member Avatar for Damian Dalton
0
198
Member Avatar for AdamLad3

Learning how to manipulate data in arrays is a useful skill to have. Therefore I suspect that this is whay your instructor has provided you with this project. Clearly, there are several approaches that could be used, some more sophisticated than others, and you will get a wide variety of …

Member Avatar for Damian Dalton
0
1K
Member Avatar for while(!success)

try parsing the expression by spaces putting every token into a string and converting to numerical values when not an operator. Operators have length one and aren't digits (assuming the compound operator like +=, /=, etc aren't allowed) and no space between negative sign and first digit (or decimal point) …

Member Avatar for WaltP
0
2K
Member Avatar for triumphost

The memory is only "lost" while you are running the program. Once program is completed any "lost" memory is freed up by the operating system. Yes you should use delete if you used new to create a member variable within an object. It may, or may not be appropriate to …

Member Avatar for triumphost
0
762
Member Avatar for kuramahiei

said another way. >> ignores the terminating new line char left in the input buffer (if any) by any previous input method, but get() does not, and it leaves the termniating newline char in the input buffer when removing input from the input buffer. So, upon hitting the d key …

Member Avatar for kuramahiei
0
172
Member Avatar for Chuckleluck

How about an array (size 16) of c_ChessPiece pointers. That way you can have up to 16 c_ChessPieces but in any combination you want. If you have a virtual move() function in the c_ChessPiece class that is overridden by each derived class then each c_ChessPiece pointed to by the c_ChessPiece …

Member Avatar for mrnutty
0
182
Member Avatar for tom12

How did you remove spaces? Removing vowels is the same thing, except that you find a vowel instead of a space before you remove it.

Member Avatar for tom12
0
90
Member Avatar for cryonize

With power comes responsibility. Accept it and move on. BTW: good first post! code tags, question, pertinent code, wonderful. BTW: you have declared user defined types that could be used in linked lists. You haven't actually initialized anything in the code you've posted.

Member Avatar for Lerner
0
301
Member Avatar for lw2025

function calls look like: add(input1, input2);[code] get first input get operator if(secondOperandNeeded(operator)) then get second operand switch(operator)[/code]

Member Avatar for lw2025
0
148
Member Avatar for Vasthor

Listing individual items in a namespace you will use in a program and not "polluting" by writing for the entire namespace is a very acceptable method, and many would feel is the preferred method, though many of us use the "convenient" path of exposing the whole namespace.

Member Avatar for mike_2000_17
0
107
Member Avatar for ItsAdZy

The first thing I see is that valid indices for salesTotal range from 0-11 but you are trying to access elements with indexes of 1-12. Adjust the indicies so they coincide and don't access memory not allocated to salesTotal and it has a good chance of working.

Member Avatar for WaltP
0
175
Member Avatar for tom12

That removes the spaces from the display of cipher but not from cipher itself. BTW: Please use code tags to enclose any code you post to maintain the formatting you (hopefully) use when writing your code. It is a bit of a hassle if you've never done it before. But …

Member Avatar for tom12
0
135
Member Avatar for dlmagers

To start with: Welcome to Daniweb. Please use code tags when posting code to maintain the indentation you (hopefully) use when writing your code. It is a bit of nuisance to do, but once you've done it it isn't difficult, and many of the permiere responders won't read unformatted code …

Member Avatar for Ab000dy_85
0
113
Member Avatar for droneerror

Line 39 declares numberArray, but doesn't initialize it to any meaningful value. Line 43 sends numberArray to function (or tries to, leave off the [20], numberArray is the array, numberArray[20] is the 21st element of numberArray, but 20 as an index to numberArray is out of bounds).

Member Avatar for Lerner
0
120
Member Avatar for minghags

>>sorting this struct by name and surname If surname is listed first, like so: Smith, John then comparing the full string should sort by surname and then by first name. >>student student; That's not a good idea, it it's even legal. Never name an object the same name as the …

Member Avatar for jaskij
0
1K
Member Avatar for tom12

You are mixing >> and getline() in the same program. >> leaves the terminating new line char in the input buffer. The new line char is the terminating char for getline() so it sees the new line char in the input buffer left by >> as the first char in …

Member Avatar for tom12
0
139
Member Avatar for shywolf91

single that is a single vairable called single 1dArray[x] is a single element of 1dArray at index x, of whatever type is used to declare 1dArray 2dArray[r][c] is a single element of 2dArray having indexes r and c (convenient shorthand for row and column). 2dArray can be declared using any …

Member Avatar for Lerner
0
267
Member Avatar for Sheepdawg

Your use of variables, functions and if/else statements seems good. Other basics include arrays and specialized arrays called strings. If you know about them then you could tighten things up a bit by minimizing the repetitive use of the same output string, "You picked xxxxxx" over and over again.

Member Avatar for Lerner
0
245
Member Avatar for mrmodest34

Use pencil and paper to work it out. It appears that you have started with the variable called end at too high a value. Also the termination conditions might need to be adjusted somewhat.

Member Avatar for Lerner
0
196
Member Avatar for juce

Depends on the type of string. For STL string objects you can use the + or the += operator. For C style strings you can use strcat(). If this is a school project and you can't use any of the standard functions/methods, then you can use a nested loop with …

Member Avatar for mazzica1
0
1K
Member Avatar for rfrapp

>>Adding two digits together words perfectly, unless the answer is more than two digits. I'm not quite sure how to do this for more than one digit. When you can't figure something out in your head, go back to pencil and paper. Things are generally easier to figure out that …

Member Avatar for rfrapp
0
3K
Member Avatar for razes_0230

Think of a list as a treasure hunt. You need to know where to start, where to go next, and as an added bonus every time you get to a given spot you can get a piece of treasure (data, information, whatever). Each spot along the way would be called …

Member Avatar for Lerner
0
346
Member Avatar for Megann1120

if(prime = 1) that's assigning 1 to prime, not checking equality of 1 with prime.

Member Avatar for Megann1120
0
301

The End.