jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You have no data type on kilometer in your function definition, you must put (int litre, int kilometer). Also, you probably need to cast litre to double double gas = (double)litre/(kilometer*100);

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Entergrade needs to have a return type other than void.
In name you are trying to assign your string to the string array but you only have one name, so pass it in as a string and not an array of strings.
Look at the signature (the parameters) for Evaluation, they don't match in number or in type to how you have defined it. And why is Greeting taking two doubles? Make sure everything matches and makes sense.

When you are returning values from your functions to main you need to capture them somewhere. E.g., for EnterName you need to have name = EnterName(); in main().

In terms of the compiler errors, they are cryptic but try to read what they are telling you. Fix the first error in the list and go from there, usually more will disappear when you fix one.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Evaluation is just text output to screen so it can be void (your main program doesn't "need" anything from it).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

else if (grade[ctr] =2.5) should be == instead of =
main should be int main
You don't need to put void when you are calling the functions in main
Your functions don' t actually do anything and are serving more as prompts. For instance you could have

int entersubject()
{
        int subj;
         cout<<"Enter # of subjects<<endl;
        cin >> subj;
        return subj;
}

or something to that effect. It adds a little bit of extra code but since the example is meant to be illustrative your instructor may want that.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm so sorry..

I realized now that my knowledge about the programming is still weak since i not even can answer this simple question...

This is not true at all. You have a lot of knowledge you need, and you need to be able to incorporate it all in one place. Bamcclur is correct you could preferably use a for loop (I kinda had my mind stuck on you needing an unknown number of entries hence the while). So in your case, take the users input, called numberofentries or something, use it as part of the condition of the for loop for (int i = 0;i<numberofentries;i++) . Within the for loop keep a running total (write it out on a piece of paper if it helps you -- draw your loop and run through it line by line keeping track of all the variables, then go through it x number of times).
I think your psyching yourself out here, it's not that involved.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Very welcome.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

if the index is zero it has to be a<y and ctr<y in your for conditions, and the program shouldn't go past your first entry of a grade due to the above. And no, it's not the compiler :)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Still have the grade[x] in there... take the x out of your variable declarations so you can't use it by mistake.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

it has to be for(int variable = 0;variable<number;variable++) that way you go from 0 to the number-1 element of the array (as a a[4] has a[0], a[1], a[2], and a[3]

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It needs to be int grade[10]; it can't be string if you are going to do calculations with it. If you only have one g you're writing over it each time. And that course[x] should be course[a]

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
for(int a=1; a<=y; a++)
{
cout<< "Please enter your course " << n << ":";
cin>> course[a];
cout<< endl;
cout<< "Please enter your Grade: ";
cin>> grade[a];
cout<< endl;
n++;
}

Also note that arrays start at zero.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Well your cins and couts are using a variable X which is never changed in your program. You should use the loop variable as your index.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

grade[] is an array of strings, it should be ints or doubles

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Get the number of entries first. Use a while loop to get that many inputs. Keep a running sum of all the numbers (nothing needs to be stored). At this point you have an integer total and an integer count. Give you a clue, if you have (1+0+1+2)/5 = 0. Do a quick net search on casting.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What is your linker error? I was able to get it to compile for me by changing the s in start (the definition) to S.

Are you trying to compile this in VC++ 2008? If you chose a blank project it might be giving you guff about it.

Also, and this doesn't matter as much as the other stuff, but are you doing anything with your counts? You don't display them...

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

(((double) votes)/sum)*100 for each. You need the cast because otherwise you'll get rounded to zero (I went a little crazy on parentheses, but you get the idea)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

CP what if average is 29 and amount is 30 (I know in this example it wouldn't be)? Casting it still won't cure the roundoff. I know he knows how to do this, that's why I chose not to give him any starter code.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Have you covered while loops? Can you make a program that takes in 5 integers? It will be very similar. There's only one cast (AFAIK) that you need to make. Just take it a step at a time and code something...

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Compare each value to zero, if f(0) < 0 && f(1) > 0 then search in between them (so theoretically you could space your function values at say 5 apart or something and then zero in on it. 5->2.5->1.25 within one interval.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Put in an in.ignore() after the getline to catch the stray newline after the string is parsed.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Taking the first 25 it seems to be hanging up and rereading the same one for some reason

1 1 o ipod 2 203
2 1 p payment 0 20
3 1 o stereo 0 203
3 1 o stereo 0 203
3 1 o stereo 0 203
3 1 o stereo 0 203
3 1 o stereo 0 203
3 1 o stereo 0 203
3 1 o stereo 0 203
3 1 o stereo 0 203
3 1 o stereo 0 203
3 1 o stereo 0 203
3 1 o stereo 0 203
3 1 o stereo 0 203
3 1 o stereo 0 203
3 1 o stereo 0 203
3 1 o stereo 0 203
3 1 o stereo 0 203
3 1 o stereo 0 203
3 1 o stereo 0 203
3 1 o stereo 0 203
3 1 o stereo 0 203
3 1 o stereo 0 203
3 1 o stereo 0 203
3 1 o stereo 0 203

I'm still looking at it but I figured you might need this info.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

list = list_new; doesn't work. It results in the "shallow copy" where just the pointer is transferred. You need to copy it elementwise.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Worked for me even without the const on g++ 3.4.2. Was it crashing on you when you tried to run it at that point?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Not sure what the issue is, once you right click like you said you get a programs folder. Click on the startup folder then right click and drag your *.exe program (release version if you are using visual studio) into that folder and select create shortcut here. I'll ignore your sig for the time being.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

How is the file written out?
e.g. struct1.member1
struct1.member2
struct2.member1
struct2.member2

I don't think you can read it in with read() that's for char* (I see what you were trying to do with your casting). You may have to read it in member by member (if you know the order ahead of time which is why I asked that question before). Use an ifstream and go myifstream>>structure.member and as long as the types are correct it should work (do any error checking you deem necessary).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Put a cin.ignore() before your getline() there's probably junk left in the istream.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

This time you don't need all that precision. Take the fixed and setprecision statements off of the cout(I only told you 7 digits last time so you could see error at 10^-6). P is missing zero by a minuscule amount and continuing. There may be other errors because the approx is off by about 1. Also, you should check your denominator in your Laguerre's calculation against zero to make sure that won't crash the program.
I'm not sure why changing the precision would affect the calculation?? aside from the output. One thing though that this brings up is that it is difficult if not impossible to use == with floats or doubles due to these conditions where you can be so close to zero and not quite zero. So you can do things like myvariable <= 0.00000000001 or something (or take the difference between your variable and an ideal myvariable - ideal < 0.000000001 etc.).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Could be the '\n' from when you hit enter after the numeric selection, it might stay stuck in the stream.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The atoi() function should strip out the text as long as the numbers are first. Either that or you could change his getline to one with a delimiter of ' ' (space) http://www.cplusplus.com/reference/iostream/istream/getline/

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Pop a cin.ignore() between lines 32 and 33 (your input was getting corrupted, that throws out anything left over).

Also, don't redeclare answer on line 28.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

VC6, while ancient, should still have something resembling the standard includes. Your compiler at home definitely should. But... see this http://www.cplusplus.com/reference/clibrary/cstring/strcat/ for a way to concat strings

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What you are looking for is called a profiler. One of the advanced Visual Studio packages has one built in but I think it's the Team Suite. I've used a couple in C# but not in C++. Here's a thread with some options. I think people like ANTS but it costs.

I'm surprised you didn't get more ideas on here from other folks...

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I believe the method yourstringhere.data() behaves like a character array in situations like this. I thought originally you meant that you wanted to concatenate those two strings filename+".sav" but you mean that you want to convert a string to char array?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I think you described it very clearly. What I don't understand is whether or not you have access to the functions in the C++ <string> header (or even <cstring> also named in older versions <string.h>).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You're very welcome. Good luck with it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Summary of all of the above:
change poly to

void poly(vector<double> A, vector<double> & B, double x, double& p, double& px, double& pxx, int & degree);

(and if you need A for another segment of your program change it to a reference too)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I knew when I wrote that that it probably was not right. It has nothing to do with your iterations count but it's crashing in your f() method. You're passing in degree and it's garbage (I think because you needed to pass it in by reference to the poly function) and your actual B vector is of 0 length. EDIT: nevermind lol

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

How many iterations are you putting in? It may be greater than the maximum value for an integer on your machine ( I only say that because you were starting at the millions before).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

That's not garbage, that's floating point for ya. Change line 84 (just for illustrative purposes) to cout << "The next midpoint, approximation is " <<fixed<<setprecision(7)<< x2 << endl; and include <iomanip>. Your answers had some roundoff when they were displayed and that roundoff is on the order of 10^-6 hence your "garbage."

btw, I understand your response from before, but until I used it my way I was getting that nothing had roots!

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you want good ol' Win32 this is the stuff http://www.winprog.org/tutorial/ And of course there's Petzold's Programming Windows 5th Ed which is a very very highly regarded text (I've never read it but I'm not much into straight API programming).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

List is a pointer to a WeatherStation object (essentially an address). See this post http://www.daniweb.com/forums/thread11705.html (mainly for Narue's contribution) and/or google pointers, pass by value vs. pass by pointer (which is really pass by value with a pointer a la C) and there's pass by reference.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

companyImp.cpp: In member function 'int Company::read_list(int)':
companyImp.cpp:55: error: void value not ignored as it ought to be
companyImp.cpp:60: error: void value not ignored as it ought to be

What is the read_student() method supposed to return (I don't see it but I'm sure it's in another file). Or readData for that matter. If it is a void function and you're trying to assign that to flag then it's balking.

companyImp.cpp: In member function 'void Company::process_list(int)':
companyImp.cpp:75: error: 'int' is not a template
companyImp.cpp:75: error: 'size' cannot appear in a constant-expression

You have a type where a variable should be. In the condition portion of your for loop you have int < size, it should be i, and then the rest of the errors (in that grouping) will fall out
(which is commonplace and why fixing the first one can make many others go away) if (list[i].getLast() > list[i+1].getLast) you forgot a () after the second getLast

companyImp.cpp: In member function 'void Company::searchID(int)':
companyImp.cpp:187: error: request for member 'length' in 'target', which is of non-class type 'double'
companyImp.cpp:188: error: invalid types 'double[int]' for array subscript
companyImp.cpp:188: error: invalid types 'double[int]' for array subscript

target is not a string it has no length() function. I think you mean to have it as a string after all the manipulations.

I'm sure there will be other little ones along the way but those are most of the biggies. Just take it one error at …

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

Ok, but what happen if I use K>size. Can you please give the answer.

A big mess but thankfully the for loop is in place. Perhaps I don't understand your question. I suppose you could change k=0 to k=size+1 but then the loop just wouldn't run.....

If this is related to your own assignment, please start a new thread someone will help you.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Nevermind I figured it out. I just set sum=0 and everything works out, thanks alot!

Sorry about that I was building that method off the top of my head

One more question. Everytime i do Post Temperature and finish entering the temps, It loops my Menu() twices, does anyone know why it does that?

Try putting a cin.ignore(999,'\n') after your getline in main, there may be extra characters trickling through after your getline. That function gets rid of the first 999 chars until it hits a newline then it tosses that too.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
void DailyReport (WeatherStation* List, int Size)
{
	int K;
        double sum;  //pop this in here to keep our sum
	cout << "NGS Daily Temperature Report" << endl;
	cout << "================================================" << endl;
	cout << "                      Fahrenheit  Celsius" << endl;
	cout << "------------------------------------------------" << endl;
	for (K=0 ; K<Size ; K++){
		List[K].ShowTemp();
		 we're already showing the temps we'll keep track of their 
                 sum in the same loop
		sum+=List[K].GetTemperature();  access the private 
                                                              members via your "getter"
                (or sum = sum+List[K].GetTemperature();) 
                each time we add on the next temp in the list
	}
          now we have a sum of all the temps, so just divide by the size that we passed into the function
      so either    std::cout<<"The average is: "<<(sum/size)<<std::endl;
       or do something else with the sum/size quantity like
                   double average = sum/size;
}
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

declare double sum; within your for loop,
sum +=List[K].GetTemperature();
outside of for, output or assign to another variable sum/size;

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Again where is all_names coming from it's not anywhere in your code, that's the main thing that stands in the way of it compiling.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Please STOP posting on old threads. The two other people still using that version of the compiler either retired or passed away.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Here's a skeleton code:

int multbytwo(int);
int main()
{
       int myreturnedvalue;
       int myinputvalue = 3;
       myreturnedvalue = multbytwo(myinputvalue);
                         (so this has returned an answer that we can 
                           now  assign to a fresh variable)
       since it does this returning we could also do
       std::cout << multbytwo(myinputvalue);
       return 0;
}

int multbytwo(int numberIwantmultipliedbytwo)
{
     either   
            int multipliedanswer;
            multipliedanswer=2*numberIwantmultipliedbytwo;
            return multipliedanswer;
   
     or (more succinctly)
            
             return 2*numberIwantmultipliedbytwo;

}

(and a void returns nothing so either you have to pass in something (or multiple parameters) by reference or output what's going on in your function)