jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

No problem. I had fixed it on mine when I edited your code, but I didn't think to check and make sure you'd fixed it the same way. Hehe.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You might be able to get it to run under DosBox. I don't use Linux, so I don't know if it would work under something like Wine or dosemu. You should probably just use the gcc which is in all likelihood part of your distro.

As for an IDE, Code::Blocks is a nice cross platform IDE that will work in Windows and Linux. I've heard a a lot of people speak highly of kdevelop, but I have never used it.

Rashakil Fol commented: why would you mention DosBox wtf what are you thinking -2
tomato.pgn commented: If you haven't used it then wtf r u thinking to tell others... -1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yeah, you don't want line 9 in there. That will give you an extra read that you don't want.

Move lines 19 and 20 up to line 8 so that if you reach that condition, you'll exit the loop straight away (you could even combine it with the loop condition like

while(infile >> scrlist[i].athletenum && scrlist[i].athletenum != -1)

Double check that to make sure it behaves like you want it to).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Post up that section of your code (just that function) again, as I think you might have left one too many infile statements in there.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

There's no variable count in the code that you posted before. "i" can really double as the count, but the other functions aren't aware of it, so you're dumping 90 some odd entries that are not valid.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Those values are coming from uninitialized float variables. Did you print out the structs in getathletes to make sure everything's coming in okay?

I think you may want to keep a count of the number of athletes in getathletes that you can pass to the other functions so you're not dumping out a largely empty array when you output to file.

Other than that, I haven't discovered anything else so far.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes, but you can test it out for yourself, too.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Okay, so I'm asking you why you need the quotes on the string constant "Please enter the starting balance" and not on the string constant "credit." It's the same idea. You need them both. credit is a variable named credit, "credit" is a string constant equal to the word credit. You want to compare xact_type to "credit", not to credit.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Put some cout statements in the body of the function at different points to see how much of it gets executed. Check the output file, too, to see if anything is written. You never actually check to see if it opened successfully, so put in a statement or two to check that.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You've got xact_type where it's supposed to be now, he was saying take it out of the variables you were declaring as floats. That's all squared away.

You're getting closer, but how do you write a string constant -->> " "
you didn't write

cout <<Please enter the starting balance;

so why would you write

xact_type == credit
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
if(xact_type == ???)

Why do you keep wanting to find out if it's equal to itself?? Of course it's equal to itself. You want to find out if it's equal to a certain string. See if it's equal to that string. Also, else doesn't need any expression with it. Else is what covers anything that doesn't fall under the other conditions.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You don't need anything in the while loop, as infile is returning an istream reference, not the value of the input variable. Once it runs out of items, it goes to null and stops the loop.

Is there an actual line with the number -1 on it, or are you talking about EOF? If you need it to wait for an actual athlete number of -1, then still use the infile to drive the loop, but check for an athlete number equal to -1 and break out of the while loop when you hit it.

while(infile >> scrlist[i].athletenumber)
{
    if(scrlist[i].athletenumber == -1)
        break;
}

It's not dramaticaly different than what you had before, but I think it's a little more robust.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

#include <string> (you still don't have #include <iostream> listed in your code either). It's likely when you found string str; that "str" was a specific variable from someone's code. How would you declare any other variable that is of type XYZ? Nothing special for strings.

It's not good form to beg people to fix something for you. No one is going to give you the answer. In reality, you have all the answers you need to solve this, you just need to think about what you are doing and bring it all together.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Sorry, I guess those are the athlete numbers.

Change

while(scrlist[i].athletenum)

to

while(infile>>scrlist[i].athletenum)

That way you can skip having to read once before the loop, and once you run out of lines the loop will stop right away.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What are the 4,13, and 7 supposed to signify?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Please use code tags [code] //code goes here [/code]

Can you post a few lines of the input file?

One thing I noticed is if you have an error with the file, you keep right on processing the data. You need some sort of exit condition or a reprompt of the user to get a new filename (this could even take place within your openfiles). I'm not sure this is the issue at hand, though.

I'd recommend checking everything step by step. Make a one line file, and make sure it loads. Then try to read it in, checking each element as it's read. Then, get the whole file read in if you can. At that point you can think about incorporating the other functions. It sounds like it will be more time consuming, but I think in the end it will save you a lot of time.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You would still need 2 passes, once to count how many digits there are to establish the place value for the first digit, and another to read in the digits and do the multiplication.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Contact the company. If they are willing to release the code to you, they will. As it is, no one is going to help you disassemble someone's proprietary DLL.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I think (from another thread with the OP) that the get() (and perhaps unget())is the only thing allowed. I agree that there are many other easier ways to do this.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Show some effort, what have you attempted to write so far?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I need to take those individual digits the 1 9 5 6 and make it read as a whole number.

I remember this from before, but you'll have to clarify what you mean by "make it read a whole number." Like I had said on the other thread, you need to keep track of how many characters the number consists of and multiply by 10 ^ (power -1), etc.

e.g.,

1%4$%5#
//how many are digits? Determine that 3 are
//unget the last 6 characters
//multiply 1 by 10 ^(3-1) = 10^2, add it to a running sum
//march along to 4, multiply it by 10^(3-1-1) = 10^1, add to the same running sum
//march along to 5, multiply it by 10^(3-1-1-1) = 10^0,add to the same running sum

since 145 = 1*10^2 + 4*10^1 + 5*10^0
It's a convoluted way to do it (as writing out the characters as you read them is far easier), but it sounds like that's what your instructor wants.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

But still I need another answer.

Yup, he's right. Nick's been doing this for a "couple" of years. I'm confused as to what you need more answers about?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It should be

if(15 < Total_minutes <= 30){

You used '{' after if which should be "("

That won't work either

if(Total_minutes > 15 && Total_minutes <=30){
}

is the correct way to write it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You need to show some effort before anyone is going to help you. Copying/Pasting the assignment into the box is not sufficient. Can you create the skeleton for the program? can you declare the arrays? Do you know how to define a function? Give it a try and post back.

Nick Evan commented: Yep, no homework freebies here +16
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Check your compiler settings and make sure that /clr:pure is not set.

Edit: but you probably still need the plain /clr switch since you have the managed code in there

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You have redeclared "smallest" and "largest" as ints in main(). There's no need to do that.

slygoth commented: thanks man this really help +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Hint: is a space the only thing that can separate two words? Also, if the user hits enter, that's the second line. You're very close here.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I took a course in Systems Analysis and Design eons ago and was taught something like the following: http://en.wikipedia.org/wiki/Systems_Development_Life_Cycle. I'm not a practitioner, so I don't know what people actually do, but that method of analysis abstracts it a bit from compilation and testing cycles, so it may not be exactly what you want.

AndreRet commented: Payback for the other reps, thanks. +6
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Check line 36. I don't think it's the main problem, but it will catch up with you eventually.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Line 9 (second listing) should not look like that. Are you trying to call the function? It looks like a definition. Also, formatting your code with proper indentation would make it easier to spot errors with the braces. Lines 88-100 on the first listing seem like they are floating outside of any function.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Go through each element and keep track of the minimum and maximum values as you go. Also, add the element to a running sum and at the end divide by the number of elements.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Assume Lucy’s stride length is 2.5 feet. Using the fact that there are 5280 feet in a mile, have your program display the average number of strides Lucy makes in a minute (a float) and the distance Lucy jogged in miles (a float)

You have still not even matched up your prompts with those in the example. Little details are important.

You have two constants that you have not defined anywhere. Also, does your program answer the question asked??

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

getmenu() returns a char, what happened to it? (and no, it doesn't belong back as a parameter). You don't actually assign anything to op in your main(), it stays blank.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You don't need the char op in the parameter list. It's not necessary, as you're not passing anything in. The "op" that you've declared in your function is "shadowing" the one in the parameter list (the local one would prevent you from using the parameter, since they have the same name).

Nor do you need the "char" while calling the function on line 18. You need a variable to get the return from the function, but you don't need to send anything in.

Take a quick gander through some websites on functions to see examples. That should reinforce it for you.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If your function definition is after main() you need a prototype for your function at the beginning. It belongs between lines 5 and 7.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Leave your functions (addition, subtraction, etc.) as they are, though. Don't try to jam those into main.

After reiterating that bit of advice that I already stated, I am NOT doing anything more for you until line 65 disappears. You have got to be kidding me. In fact, since you're not listening, I'm walking away from this. I don't give up on people as a rule, but you've become an exception.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

First, please use code tags [code] //code here [/code].

You've been given a sample output, and your code doesn't match. Try to get your program to produce those phrases verbatim. After that, try putting in all the input steps, and then add in the math. Do it in stages like Ancient Dragon recommended.

You're answering a different question with your code, so that would have to be addressed, too.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
void InputData([B]string playerName[][/B], int score[], int addNumPlayers, int SIZE)
{
    int i;
    while (addNumPlayers<SIZE)
    {
	cout << "Enter Player Name (Q to Quit): ";
	cin >> [B]playerName[addNumPlayers][/B];
	if (([B]playerName == 'Q'[/B]) || (playerName == 'q'))
	{
		break;
	}

You're passing in playerName, which is an array of strings. The playerName variable points to the address of the first string in that array. On line 7 you are respecting this, and writing the string of the addPlayer-th element of playerName[] .
Then on line 8, you are asking the computer to compare the value of the pointer to the first string in the array to the character 'Q'.

The compiler is rightly balking. In order to get the first character of the addPlayer-th string, you need to access playerName[addPlayer][0] which is one character. The first index gives you the entry in the array and the second gives you the character. You could also do something like std::string temp = playerName[addPlayer]; and then access temp[0].

Of course, the above approach will fail with a player name "Quisenberry." So you may want to compare playerName[addPlayer] with "Q" (notice the double quotes).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Okay, post what you've got.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

i have a hard time believe that theres no way to clear a terminal screen

That's not what we've been saying. There is no standard way to do it that is portable across all platforms. If you don't want to listen to my advice or to WaltP (who's been doing this kind of thing for a couple of years now), there are plenty of other people who will tell you the same thing.

try to make everything encapsulate inside main();

Leave your functions (addition, subtraction, etc.) as they are, though. Don't try to jam those into main.

WaltP commented: Couple of years? Hmmmm... :o) +15
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I had told you to move lines 29-31 out of the function and into the main() and between lines 7 and 8 of your second listing. If there's no input being taken, s2 is just uninitialized the way that you have it.

You're listening to about every third piece of advice from ntrncx or myself, and this is hindering this process considerably. We've both told you not to call main, and there it is, over and over again.

i dont know personaly other way for clear screen except system("CLS");

There's really no portable way to do this, AFAIK. People that develop text-based applications will tell you that clearing is more of a hindrance to the user than a help, but if it's part of your assignment, you may have to use it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you've gone through 3 passes over the list already, what will be the bottom 3 numbers?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It's asking you for the order during an intermediate point in the sorting process. You've swapped everything around for x = 0 (and the lowest number is in the first element), then done the second pass over the whole array for x = 1 (now the second lowest element is in place, now you're on the third pass over the array (x=2). Y shouldn't ever be 4, but presumably they are saying you've done all the swaps for the third pass. So it will be the two highest elements that are in question.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Okay. The short answer to all of them is no. There are some different ways to get behavior that is similar. This thread on stack overflow talks about some of those things. http://stackoverflow.com/questions/9321/how-do-you-create-a-static-class-in-c.

To get a class that is not allowed instantiation, you need a pure virtual function to make that class abstract (see http://www.learncpp.com/cpp-tutorial/126-pure-virtual-functions-abstract-base-classes-and-interface-classes/ for a great explanation).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Not a problem, thanks for being a good sport. See for your own benefit if you can figure out how to change the code to make it descending.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
-6 1 3 8 10

Is correct :)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I understand, but I don't want to take away your fun, this is a good learning exercise. Trace it through by hand for all of the x values and all of the y values, and actually do the swapping. Start out with, is 3 > 10, no, so you leave it alone, is 10 > 6, yes, so swap them. The sorting order will start to be apparent after a few moves.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Okay, well, if you can't compile and run it to see the answer, then you have to be the compiler. Trace it through by hand on a piece of paper, writing what the array looks like after each step.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm confused. What values? Why don't you type it in and compile it?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You've provided an excellent answer, vikashj, except that new and delete are not going to work in C.