jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

int findMax(int [][20]) needs to be int findMax(int grade[][20]) 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.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

My guess would be that you needed to qualify fixed in your code with the ios:: namespace if you didn't have using namespace std; in your code (which you shouldn't do anyway). I'm not entirely up on how ios and iostream are woven together, though I think ios is the base class.
In this example, using setf in place of the manipulator "fixed" basically accomplishes the same thing, changing the flags to reflect that the output should be fixed-point.

In terms of the general concept, look around about namespaces and the using directive (there's a lot on this site as to why you shouldn't bring the entire std namespace in). There are lots of examples of how to use it more effectively with e.g., using std::cout; so you don't have to qualify the often-used method.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It really is as simple as

int count = 0;
while(inFile >> student[i])
       count++;

because each time that loop condition is tested to see whether or not to proceed with the loop, you get a character. When characters are no longer able to be read, the loop halts. Now you have your characters and you have your count!

(Ignore the thing about layout I should have checked it _before_ I posted it, it turns out not to matter)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

A compiling program is not necessarily doing what you want at runtime.

I still think the while loop is your best bet as long as that's been covered in the class. Read about all the behind the scenes work that ifstream is doing for you. Then you won't have to worry about the loops since you'll have your count.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

No problem at all!

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

that worked! inside the else block i had to set ptr=first; instead of *ptr=first;

Sorry about that. I was going to compile an example to make sure I told you that correctly and I got side tracked.

Anytime you have a set of braces a new scope is set up, meaning (among other things) that anything that is declared on the inside is not visible outside. But anything visible outside is visible inside, so you could have initialized your variable outside of the else statement. I was just trying to help you keep your code together. The thing about the braces is, once you close that scope, anything declared inside disappears (just like with functions and local variables). So you were trying to return something that no longer existed.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

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 learned while loops you can use a for loop but keep track of count separately from the loop counter.

There are a few inconsistencies with your for loops. In the first one, you're incrementing count in the body of the loop as well as in the loop conditions. Your count will reach the amount "questions" twice as fast.

In the last loop, your condition is i<count-1 but this way you will miss the last element of your array as indexing starts at 0 and count-1 will be the last index but as you have it it will stop at count - 2.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

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

MooAndStuff commented: Solved my problem =) +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You're never updating counter in GeneticAlgorithm::GeneticAlgorithm()

I think you should change checkanswer to a bool

while(counter < 50) //keep going until we find the answer, or until 50 iterations occur
         {
            if(checkAnswer()) 
                     break;
//check to see if we have an individual with the correct answer
           
            Optimize(problem, populationSize,mutation_rate, mutation_amount); //if not, proceed with breeding and replacing

			counter++;
         }

Then prompt user for another 50 (unless these take the 5M iterations you were talking about before). Or isolate the Optimize function and see if it converges after a reasonable time.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

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,

string dayType::printDay(){
        cout << (weekDay + (currentDay-1));
}

string dayType::prevDay(){
  cout <<  (weekDay + (currentDay - 1));
}

Neither of these return strings, nor can you just use << operator on an object without that object having overridden operator <<.
(see http://pages.cs.wisc.edu/~hasti/cs368/CppTutorial/NOTES/OVERLOAD.html or there's many more pages out there)

There may be other issues but those are the big ones holding you up right now.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

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 make an int variable to keep track of maxindex.

Also, please use code tags next time

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Try it as:

cout.setf(ios::fixed);
cout << setprecision(1) << "Mean: ";

Instead of: cout << fixed << setprecision(1) << "Mean: ";

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

when you generate firstRandom and secondRandom in BinarySelection. Your random values permit index values equal to the population size which will overrun your array.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

See http://www.nrbook.com/a/bookcpdf.php 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 just a matter of how precise your answer needs to be. Data is usually available for the tolerance of doubles and long doubles on a given compiler/machine. Sometimes the best solution is to test out your implementation with a poly that you already know the answer to and see how quickly it converges. Hope that helps a bit.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Your random number code is off by 1. If you want to get numbers between 0 and populationsize-1 just do rand() % populationsize . Make sure you seed it somewhere (only once) with srand()

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
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);
}

You're trying to use a value returned by this method in a later calculation GeneticAlgorithm::Optimize() , but BinarySelection returns nothing (I could be wrong about this but since you have it returning int and actually send nothing back the compiler may be putting a default in there).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

randomNumber could be equal to playingDeck.Count which will cause arraybound exception.

the Next() of Random goes from (inclusivelowerbound,exclusiveupperbound)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I hadn't seen OP's original, else I would have referred OP back.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It might be that when you have 1 item left, your generator is picking the index of 1 (since you don't allow for the 0th index at all for whatever reason). deck[1] doesn't exist anymore it's deck[0]. int randomNumber = r.Next([B]0[/B],playingDeck.Count);

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

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

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Construct a string with string s; s = "C:\\Program Files\\Java\\jdk1.6.0_"+num; . 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".

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

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.

static void Main(string[] args)
        {
            
            string name;
            int pds;
            int ozs;
            string another;
            do
            {
                //your other code here
                namePdsOzs(out name, out pds, out ozs);
                Console.WriteLine("Enter another? (N or n to exit)");
                another = Console.ReadLine();
                             
            } while (another.Substring(0,1) !="N" && another.Substring(0,1)!="n");

        }

        static void namePdsOzs(out string name, out int pds, out int ozs)
        {
            //read in name,pounds,ounces, do any conversions (so you   
            // may need to modify the return

        }
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

That's for the backslash. You can modify as to whether or not you want the name backwards or not. It seemed like you had the forward slash down.
If you are confused write it out!! write down what array character you need when and try to work that into indicies as you move along the for loops.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Something like this? I can't tell without knowing what your functions are doing:

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;		
	}
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

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.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I had tried Ancient's suggestion and wasn't able to get it to work (but it's a sound idea so it's more than probable that's on me) but when I took your example .txt file and removed the spaces from the strings (you could replace them with underscores which would be easy to strip for use in the program) it works with savedGame >> armorName .
Here's my output from your program.

25
25
10
2
13
12
11
0
IronShortSword
3
2
0
SoftLeatherArmor
2
2
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

sizeof( any pointer ) is always the same -- sizeof returns the number of bytes it takes to store the address of the pointer, not the length of the string the pointer references. So lines 12 and 13 of your code will always return the same value (probably 4).

line 14: you are attempting to store an unitialized pointer into the vector. undef points to just some random memory location, and that may cause a seg fault, especially if you later attempt to do anything with that pointer.

It was meant as an illustrative example more than anything... line 14 was my attempt to reproduce his error which did manifest but I understand your point about it failing in the future.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

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

#include<iostream>
#include <vector>
using std::cout;
using std::endl;
using std::vector;
int main()
{
	vector <char *> charvec;
	char * undef;
	char * word = "statement";

	cout <<"Char*"<<" "<<sizeof(char *)<<endl;
	cout <<"word"<<" "<<sizeof(word)<<endl;
	charvec.push_back(undef);
	cout <<"undef push succeeded"<<endl;
	charvec.push_back(word);
	cout<<"word push succeeded"<<endl;
	return 0;
}
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Don't use the getline methods, just redirect from the stream as you would for any of the other variables (e.g, savedGame >> weaponName; 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 it further). AFAIK, you can chain all those inputs into one statement with savedGame >> var1 >> var2 etc etc.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm going to go out on a limb and say that it's probably a school assignment so the OP probably can't incorporate it but he/she can get some good ideas from it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I think the bottom line is that you need some kind of "base case" for your recursion. See this page:
http://www.java-tips.org/java-se-tips/java.lang/finding-greatest-common-divisor-recursively.html
(the language is Java, but the concept is identical)

if (b==0) 
     return a;
else
     return gcd(b, a % b);

The b==0 is their base case, like f(0) = a

Also, along with the above, you should get rid of the for loop as you are letting the recursion go through your values rather than iterating over them.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

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 if (bokstav != gjettet_bokstaver[array_size]) . Just rereading it now, do you mean for array_size in the second if statement to be arrIndex? (realizing that you are usually dealing with the last character entered maybe it needs to be how you have it). Even though I know what the code is saying I'm unsure of the text and the variables, so apologies and hope that helped if even just a bit.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The book directs us to include global arrays that will hold this information and than pass them as arguments into the bookInfo function..

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 book is it may I ask? (forgive me if this is a little OT)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
Barcode::Barcode(int zipcode)
{
          take in zipcode, convert it (with the built in function )and assign to internal barcode value

}

Barcode::Barcode(char Bar)
{
set internal barcode to value passed in


}

Barcode::Barcode()
{
     do nothing or establish defaults (ex. barcode = 00000 or zipcode = 00000  

}

Since you have no private variables to assign any of these to, you need to make some. Check on what your text has to say about them.

These c'tor definitions would go before your Barcode::convert() definition.

Looking back, probably your best bet in main would be to not use your convert function statically but to create individual barcode objects.

Skim over your text on instantiating objects out of your classes. In summary, you probably need an overhaul but it shouldn't be too involved.

P.S. I'm not trying to cast you off or anything, far from it, I just think you should rethink the requirements a bit more. You have a couple of good functions with your class, but what is the most effective way to use them so your code is object oriented. You want your objects to be initially given a barcode or be given a zipcode to convert to a barcode. How can you store all of that content into that one piece of information.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You have declared three different constructors for Barcode: Barcode(int zipcode); Barcode(char bar); and Barcode() 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).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

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

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

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 not the signs. do the same thing for the denominator after you've seen the / and then do any parsing necessary on the strings. Multiply your numbers by sign after they are parsed and present your answer.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

http://www.cplusplus.com/reference/iostream/manipulators/setw/
(it may be right justified by default, I've forgotten) cout<<setiosflags(ios::right)<<setw(10); http://www.cplusplus.com/reference/iostream/manipulators/setprecision/ cout << setiosflags(ios::fixed) << setprecision(3); and be sure to #include <iomanip>

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

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

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It's out of date and simplistic but I'm sure you could use this general idea
http://jrgraphix.net/research/flash-dock-mx-2004.php

You could customize your own keyboard but (I hadn't realized this until now) http://www.microsoft.com/windowsxp/using/accessibility/oskturnonuse.mspx

This kind of thing is outside of my purview but it sounds interesting.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What do you mean by "it"?

Apologies, I meant the group policy management console, which allows you to disable e.g., Run... command (that you can even do from Tweak UI) but probably most things you can imagine. This link says it does run on XP, evidently.
http://www.microsoft.com/downloads/details.aspx?familyid=0a6d4c24-8cbd-4b35-9272-dd3cbfc81887&displaylang=en

I was just backing up Ancient's notion that it's probably a lot easier to make do with what windows already has built in than to try to secure a flash application. You could use flash to write a funky "application dock" that goes in place of the start menu.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

This looks like it only works on Windows server but a search of "GPMC Windows XP" does bring up some hits.

http://technet.microsoft.com/en-us/windowsserver/grouppolicy/default.aspx

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

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. struct calcType {int add; int sub; int mult; double div; int mod;}; myCalc.div = (double)numOne/(double)numTwo;

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

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.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
testnum = rand() % size + 1;
               if(!numOK(latinsq,i,j,size,testnum))
				continue;
		else
				latinsq[i][j] = testnum;

for the inner for loop. Since it's done this way you'd have to rework your outer loop(s) to prevent the program for getting trapped. You could make the outer loop a while and check the program in each of the unoccupied positions. That's changing a lot but I haven't gotten it to a point where it converges.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I can't think of one but that doesn't mean anything. I did a quick net search and it's completely sensible: if you use a queue and a stack together (pushing it onto the stack and popping an element off as you pull one from the queue and comparing them). I didn't find much at all for those using queues exclusively. A double ended queue would work but that's not the specification you were given with the queue.h.
It's great if you can come up with a faster solution but it may take you more time than it would to cobble the rest of this one together.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

srand(time(0)) goes before rand() and then you don't need the time(0) portion to generate your number. Test it out, but I think it should be rand()%size +1 .

You still have only 1 test number per run of the program, you should probably be generating a new random number within your for loop. The real problem is that once your function is returning false for the first value put in, your while loop goes forever. Inside your for loop you should probably have an if statement - if it doesn't fit in the puzzle, throw it out and continue the loop else put it in the puzzle.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The string stream part will take the longest but it's not too big of an undertaking.
If your stream has racecar (7 chars) in it, you would start at one end of the stringstream and queue up r-a-c (up to lenght/2-1), throw away the 3rd element -e-, start a new queue and pull from character 6 (r), character 5 (a), character 4 (c) and fill it in that order. Now you have 2 queues that you can compare character by character. Now you don't have to do anymore reversing which takes out that glitch (until you get to deques in your course lol). You're doing your reversing at the string level and still obeying the rules of your queue data structure.
I hope that helps. If you've come this far you certainly have enough to see this one through to the finish. Look up the specifics for stringstream in your text or online.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

This may be helpful to you if you are sticking with sstream:
http://www.cplusplus.com/reference/iostream/istream/seekg/