2,045 Posted Topics

Member Avatar for KRal

You're passing a char into your DrawBar() function which is incorrect. Keep a separate int counter to keep track of your guesses and then give that to Drawbar after a guess. You'll never be entering in the characters '1' '2' '3' '4' '5' as part of your alphabet guesses so …

Member Avatar for KRal
0
186
Member Avatar for nick30266

Take in 2 doubles from the user and then use your constructor to create a new object. [code] double r,im; cin >> r >> im; complex num(r,im); [/code]

Member Avatar for mrnutty
0
347
Member Avatar for jinjishu

int findMax(int [][20]) needs to be [icode] int findMax(int grade[][20]) [/icode] Definitions always need the identifier, declarations do not. There's no identifier there so the compiler reflects a mismatched brace somewhere even though there isn't.

Member Avatar for jinjishu
0
366
Member Avatar for denizen08

See [url]http://www.nrbook.com/a/bookcpdf.php[/url] section 9.4 (you need some stupid plug-in in addition to Acrobat Reader but if you're in this line of inquiry this book is gospel). It does not provide a clean answer to this but does have a calculation for how much the error changes at each step. It's …

Member Avatar for denizen08
0
184
Member Avatar for maverick405

I think your || should be && cause 89 is greater than 60 so it short circuits and you get anything over 60 as a D.

Member Avatar for maverick405
0
133
Member Avatar for bpt0004

[code] int GeneticAlgorithm::BinarySelection(int populationSize) { firstRandom = static_cast<int>(( static_cast<double>(rand()))/ static_cast<double>( RAND_MAX) *(populationSize-0 + 1) + 0); secondRandom = static_cast<int>(( static_cast<double>(rand()))/ static_cast<double>( RAND_MAX) *(populationSize-0 + 1) + 0); } [/code] You're trying to use a value returned by this method in a later calculation [icode] GeneticAlgorithm::Optimize()[/icode], but BinarySelection returns nothing (I …

Member Avatar for bpt0004
0
99
Member Avatar for Cold_Demon388

Try it as: [icode]cout.setf(ios::fixed); cout << setprecision(1) << "Mean: "; [/icode] Instead of: [icode] cout << fixed << setprecision(1) << "Mean: "; [/icode]

Member Avatar for jonsca
0
481
Member Avatar for Jaydenn

Construct a string with [icode]string s; s = "C:\\Program Files\\Java\\jdk1.6.0_"+num; [/icode]. Then if (Directory.Exists(s)) is true, then output the substring of s that has "jdk"+ a string with "version" + the other stubstring "1.6.0_1".

Member Avatar for sanch01r
0
155
Member Avatar for jigglymig1

Have you learned while loops? Then you could use while(inFile >> student[count]) and increment count in the body of the loop. That way you'll be able to use that count in a subsequent for loop to display your array rather than displaying empty portions at the end. If you haven't …

Member Avatar for jonsca
0
89
Member Avatar for Alinthea

If you are using a for loop to print your stars, why not have another for loop to print spaces? So run one for loop to loop over the # of lines you need and within that have 2 for loops (stars and spaces). Hand code it to convince yourself …

Member Avatar for mrnutty
0
89
Member Avatar for MooAndStuff

Declare [icode] Node<L>* ptr; [/icode] inside your method but outside the else block. Then inside of else set [icode] *ptr = first; [/icode] You might need to change what you return but I'm not absolutely sure.

Member Avatar for jonsca
0
105
Member Avatar for kz07

The first problem is with your constructor, you have it as taking in a string but in the constructor definition you don't give the string a name nor assign it to anything within that constructor. Also, [code] string dayType::printDay(){ cout << (weekDay + (currentDay-1)); } string dayType::prevDay(){ cout << (weekDay …

Member Avatar for jonsca
0
90
Member Avatar for bigskinny1989

Make a variable: double maxtemp = 0; (so that you're ensured it will be lower than any of your values). As you are going through your for loop t `if celdeg[k] >=maxtemp, set maxtemp = celdeg[k]`. If you need to keep track of where that occurs in your array, simply …

Member Avatar for jonsca
0
96
Member Avatar for dgr231

Don't use the getline methods, just redirect from the stream as you would for any of the other variables (e.g, [icode] savedGame >> weaponName;[/icode] and same for armorName). If you are writing the files manually it's finicky about the booleans (requiring 0 or 1 representation, I think I didn't explore …

Member Avatar for dgr231
0
243
Member Avatar for memory100

Here's a brief skeleton that you can work from. It seems like your instructor wants you to break off the methods (no functions in C#). There's an example do while loop along the lines. Flip ahead in your text to learn more about methods or do a quick net search. …

Member Avatar for Geekitygeek
0
105
Member Avatar for wesleychin

At least post the section of the code you are having trouble with. People like to keep stuff in the forum so everyone can learn (among other reasons).

Member Avatar for Geekitygeek
0
138
Member Avatar for sebassn

Something like this? I can't tell without knowing what your functions are doing: [code] for (int i = 0;i<mystring.length();i++) { for(int j=0;j<i;j++) cout <<" "; cout<<mystring.substr(mystring.length()-1-i,1)<<endl; } [/code]

Member Avatar for sebassn
0
88
Member Avatar for scott6480

why don't you create a struct called menuitem that can store the description/price/etc of one item. Then make an array of all the menu items selected for the order. You could call up the menuitem with a unique key (1,2,3,4...} stored within the struct menuitem.

Member Avatar for jonsca
0
87
Member Avatar for CyberPirate1

I was going to suggest using a flag in this if statement as to whether or not you'd found the character included, but I don't know if that's the best practice [icode] if (bokstav != gjettet_bokstaver[array_size]) [/icode]. Just rereading it now, do you mean for array_size in the second if …

Member Avatar for Geekitygeek
0
145
Member Avatar for Deadmon

I was able to run the following code on my machine. Word* has the same size as char *. I don't know if maybe I'm missing something or if the conditions are different (I'm using gcc 3.4.2 in Vista64). [code] #include<iostream> #include <vector> using std::cout; using std::endl; using std::vector; int …

Member Avatar for Ancient Dragon
0
165
Member Avatar for choosenalpha

Calculating commission at the beginning like that will just calculate it once, and with the wrong amount for the sale. Firstly, turn the whole thing into a do while loop because you have a while at both ends and that doesn't make sense. Then make commissionA, commissionB and commissionE variables. …

Member Avatar for choosenalpha
0
422
Member Avatar for squigworm

[Quote] The book directs us to include global arrays that will hold this information and than pass them as arguments into the bookInfo function.. [/QUOTE] Getting you into the really bad habits early, eh? I don't fault you in any way for the text that the instructor chose, but what …

Member Avatar for squigworm
0
138
Member Avatar for dinamit875

[icode] typedef struct teams; [/icode] should be [icode] typedef struct TeamInfo teams; [/icode] Change your cout on line 67 above to cout <<variable1<<"\t\t"<<variable2<<"\t\t" etc. etc. There are major issues with scope too but grab the basic stuff first.

Member Avatar for dinamit875
0
291
Member Avatar for book_worm

I think the bottom line is that you need some kind of "base case" for your recursion. See this page: [url]http://www.java-tips.org/java-se-tips/java.lang/finding-greatest-common-divisor-recursively.html[/url] (the language is Java, but the concept is identical) [code] if (b==0) return a; else return gcd(b, a % b); [/code] The b==0 is their base case, like f(0) …

Member Avatar for jonsca
0
114
Member Avatar for Jfunch

You have declared three different constructors for Barcode: [icode]Barcode(int zipcode); Barcode(char bar); and Barcode() [/icode] If you declare any other constructors and then a default one, you must define that default constructor (in fact in your file you don't have _any_ of them defined).

Member Avatar for jonsca
1
92
Member Avatar for godsgift2dagame

[icode] tally[i+2] != tally[i] || tally[i+1] [/icode] (line 34) is not doing what you want it to do. You need [icode] (tally[i+2] !=tally[i]) || (tally[i+2] !=tally[i+1]) [/icode].

Member Avatar for godsgift2dagame
0
101
Member Avatar for wyett

check the first field to see if it is +,-,or a number. if it's a sign or a number, take in the next number etc. until you reach / (so in your mixed number example you invalidate the input based on the space). read your numbers into a string but …

Member Avatar for jonsca
0
90
Member Avatar for jennwenn25

Make the div element of your structure of type double. Then cast one (or both of numOne and numTwo to double before performing the calculation. [icode] struct calcType {int add; int sub; int mult; double div; int mod;};[/icode] [icode]myCalc.div = (double)numOne/(double)numTwo; [/icode]

Member Avatar for jennwenn25
0
140
Member Avatar for jiten_raulo

in a class (or struct) where c is a pointer to said class and member is a public method of c (can be a public field also) c->member() is the same as (*c).member()

Member Avatar for dkalita
0
81
Member Avatar for Syakoban

This looks like it only works on Windows server but a search of "GPMC Windows XP" does bring up some hits. [url]http://technet.microsoft.com/en-us/windowsserver/grouppolicy/default.aspx[/url]

Member Avatar for Ancient Dragon
0
98
Member Avatar for jtddogg

Except you need to move the average calculation outside the for loop so it's not done each time. You should cast total to a double before the division so that your average isn't truncated.

Member Avatar for mrnutty
0
123
Member Avatar for amishraa

Why are you calling resultsfn with only 5 parameters when it takes 11 in your prototype and definition? It will not assume defaults for those. Often what the compiler says, goes.

Member Avatar for amishraa
0
137
Member Avatar for openoutcome

You should probably use [icode] srand(time(0)); [/icode] at the top ([url]http://www.cplusplus.com/reference/clibrary/cstdlib/rand/)and[/url] do your subsequent calls to rand() % dimension (not rand %100 as a 3 by 3 is not going to need numbers up to 99). As it is your program is trapped on one value and it keeps looping …

Member Avatar for jonsca
0
960
Member Avatar for NinjaLink

Something weird is going on with your streams they are getting lumped together if your queue starts out empty [code] Printing pre-reverse U From the print step ------------------------- Printing reversed U (R) From the print step ------------------------- Printing pre-reverse U From the print step racecar ------------------------- Printing reversed U (R) …

Member Avatar for NinjaLink
0
199
Member Avatar for NinjaLink

That's the purpose of the assert, to halt the program if a particular condition is not met. So you're calling your [icode] front() [/icode] or [icode] back() [/icode] methods on what apparently is an empty queue.

Member Avatar for jonsca
0
109
Member Avatar for Ineedhelpplz

I won't pretend to be an expert but I'm nearly 100% that you can just write a normal for loop and get the exact same results, but it completely depends on your compiler and system. [url]http://books.google.com/books?id=mM58oD4LATUC&pg=PA228&lpg=PA228&dq=register+keyword+C&source=bl&ots=rn-80oICcn&sig=siWxPD99jsGYpXrKp8ZszMJhSec&hl=en&ei=T7T5Sv78KIecML6OsNwK&sa=X&oi=book_result&ct=result&resnum=9&ved=0CB4Q6AEwCDgK#v=onepage&q=register%20keyword%20C&f=false[/url] Also see: [url]http://www.daniweb.com/forums/thread19956.html[/url] (post #17)

Member Avatar for jonsca
0
91
Member Avatar for liemonline

Maybe I'm missing something, but do you actually create myIntList (instantiate your List object) before you attempt to use it in main()?

Member Avatar for jonsca
0
1K
Member Avatar for vinochick

should be [icode] if(pkg == 'A' || pkg=='B' || pkg == 'C') [/icode] otherwise they won't match character for character. Your switch statement should look like: [code] switch(pkg) { case 'A': //case A goes here break; case 'B' : // case B goes here break; etc. } [/code]

Member Avatar for jonsca
0
765
Member Avatar for maverick405

Before the cubing step values[] = original value squared, so saying cubed = values[]*values[] = originalvalue squared * original value squared = original value to the fourth. Also in your parlance, cube_root is the same as cubed which it is not (e.g., cube root of 27 = 3). So, ultimately …

Member Avatar for abhi_elementx
0
2K
Member Avatar for rysin

[quote]Then it gives you the option to send an error report or dont send. How do I get that to go away? [/quote] Write a program that doesn't overstep your name array and crash. Only giving you a hard time... There isn't a next element to test after "Tim."

Member Avatar for jbennet
0
129
Member Avatar for yatman

See [url]http://www.cplusplus.com/reference/iostream/manipulators/setw/[/url] That way the widths of your fields will be constant and you can use your ostream directly without all that mildly stressful string manipulation.

Member Avatar for yatman
0
171
Member Avatar for sebassn

You still have the endl (s) in your code. You need to get rid of those otherwise you will be printing out stars and spaces with a carriage return line feed after them. Here's a hint - on the way down you're subtracting one space, once you get to the …

Member Avatar for restrictment
0
838
Member Avatar for blamp

Also see my post in your other thread about the flaw in your multiplication... Stu, I'm thinking having 2 functions (one operator and one non-operator) might have been part of the assignment.

Member Avatar for jonsca
0
105
Member Avatar for konefsta

Seem to be missing semicolons after your class declarations in the headers: [code] class Feature { private: int Id; int Frequency; string Description; public: void setId(int i); void setFrequency(int f); void setDescription(const string d); int getId(); int getFrequency(); string getDescription(); Feature(int i, int f, const string d); }; <-------------- (and …

Member Avatar for jonsca
0
185
Member Avatar for blamp
Re: help

Your multiplication and division functions are incorrect. A/B * C/D is simply (A*C) /(B*D) you have some extra factors in there. Your numerator for the division function is actually the correct amount, so just separate that into the numerator and denominator. Scratch some examples out on paper to convince yourself. …

Member Avatar for jonsca
0
105
Member Avatar for Gem74

EDIT: missed how it was before. But your Node itself has a default constructor taking no arguments. I think the problem lies in all the private inner class friend layout that you have. I understand that you may have a requirement for data hiding but I can't quite wrap my …

Member Avatar for jonsca
0
151
Member Avatar for lexsoOr

[icode] cin << info; [/icode] is incorrect, the [icode] >> [/icode] operator should be used instead. Probably just glazed over it because you had it right the other times.

Member Avatar for lexsoOr
0
88
Member Avatar for sebassn

Don't use the endl as that's moving each * onto it's own line. You have the right idea with 2 for loops. Are you prevented from adding a third to step through each line of the diamond? You might use some if statements, placed strategically to decide which of the …

Member Avatar for jonsca
0
93
Member Avatar for calypso&noname

Why can't myName() return a string instead of an int? Also, the restriction on cout seems to be for your function body only. Great post title, BTW.

Member Avatar for calypso&noname
0
146
Member Avatar for tina05

Check out: [url]http://www.parashift.com/c++-faq-lite/templates.html#faq-35.13[/url] It's touchy about template parameters being defined in separate compilation units. It probably has to do with your DataType parameter being used in a function with your T parameter in main. I did not try your code so I'm not positive. P.S. What's up with that font? …

Member Avatar for jonsca
0
379

The End.