jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It works if you get rid of getline(inFile, Library.genre); I didn't try it but it might have worked with inFile >>Library.genre, but mixing getlines and >> can cause trouble. The second argument to getline should be a string.

There are some problems in the addRecord method (you need to probably make a loop in the main method to get additional records and pass in the i value to addRecord and you need to declare albumName locally if you want to read into it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Can you put up a sample text file?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

genre should be of type songCategory in your struct instead of string. Then your other code should work.

Also, you do not need to specify the =0, =1, =2etc in the enum itself since those are the default values so you can have enum songCategory {ROCK,ALTERNATIVE, etc,etc}

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Your if statements should look more like this:
(you must change the y<=X<= z statements but you don't absolutely have to have the else if, but it's more efficient if you don't have to go through a bunch of if statements)

if ( comission <= 299 )
	        ++count1;

	else if ( comission>=300 && comission <= 399 )
	        ++count2;

	else if ( comission >=400 && comission <= 499 )
		++count3;

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

No, you want to go from 0 to side, since you loop is j<side, in this case side is 4, giving 0 1 2 3 (so 4 stars). You don't need the star at the beginning either.

So it goes:

for loop (over the rows)
{     
         for loop over the stars
         {
                 Print stars
         }

         line break (cause once we're done here we're off to the next row 
                           in the loop)
}
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What code do you have so far and what difficulties are you having with it?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Hint: Only use the outer for loop to control the lines, use the inner for loop to control the number of stars on each line. So therefore, you only need to put in the line breaks at a certain point.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

dont use black screen please

I'm not sure what you mean by that.

No one is going to write the program for you, and definitely not with Borland anyway. Instead, we will help you with what you have coded.

In starting out, you should have an array of ints 26 elements long (one for each letter of the alphabet) and increment the appropriate counter when you process a letter.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm not sure I understand why Maximum is a string? If it is you can't use the < with it.

This is one of those things that within that loop you need to have a variable called maximum (an int) and one called maxteam(a string), you can test each incoming score against the maximum, if it's greater set maximum to that current score and maxteam to that current team.

Also, the way you have it set up, the second time through the while loop you'll be at the end of the Games array (since the first time through the while loop, the for loop will run up NumGames). So you should probably keep a different variable for your array count to move that along.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Hey all,
I'm usually over in the C++ forum most of the time but I had a question that's been lingering for a while. I've got Windows Vista 64. I use Kaspersky AV, 2009 (v. 8.0.0.454,latest DBs) and about 3 months ago the Windows Security Alert (Red Shield with X) showed up in the system tray saying that "Windows didn't find any AV software on this computer." I went to the Kaspersky boards but folks were kind of equivocal about whether this was a bug or not.
I've ran all kinds of tests (latest MBAM which about 2 weeks ago found 2 malware exes in the recycle bin-- I presume were rogue email attachments on spam which were only chucked and never ran-- which were clean on a second scan),Ad-Aware (and a Hijack This in case it turned up something I could post it here), but everything turned up negative.
My question (so this doesn't become a novel) is whether this is a known problem with Kaspersky? or is it still possible that something has severed the ties between Windows and the AV or worse?

Thanks for your help.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Well, what is that brace on line 29 closing? Nothing. Your other for closes on line 12. Is there some kind of brace matching in whatever editor you are using? You can use that to run through them.

Also, more importantly, you can't just use << with arrays. You need to write a for loop to print out the individual members.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You can declare an array dynamically: see this for a good example. However, if you have been taught vectors there is virtually no reason not to use them (I could see a case where you had a requirement for very very low overhead). The vector will expand automatically if the need for more storage arises, so you can pack stuff into it for quite a while before you even had to think about it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Try something like this:

for (int i = 0; i < row; i++)
{
      cout << "\nPlease enter the numbers for the "<<(i+1)<<" row: ";
      for (int j = 0; j < column; j++)
       {
                cin >> myArray[i][j];
        }
}
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Extra semicolon on line 17: if(At_Bat >= Hit);

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

In main() you don't need the void in front of displayBoard() like you do in the prototype up above.
Is there no definition for the displayBoard() either?
It doesn't seem like you have quite enough to be running it yet. It might compile but that's just a step in the right direction.

Also, next time please use code tags surrounding your code, it's part of the site rules and makes it easier to read.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You don't need it:

int i = 0;
while(input>>employee[i].spotnumber)
{
      input >> employee[i].driver_name;
      input >> employee[i].car_reg;
      i++;
}

Search the threads on this site about eof and why it's not reliable. E.g., http://www.daniweb.com/forums/thread19956.html , post #18 on that thread. (that thread/article is also the 5th sticky post down at the top of this forum)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You need downcasting(downcast your base class pointer to a pointer to your derived class -- go "down" the class hierarchy). See this for a good example (aside from the initial post).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

ps my code for some reason keeps shutting down my computer as well.

Wow that's not supposed to happen. I'd look to other causes unless you mean that your VC# crashes and takes down your PC.

To give you a good clue, here is the proper way to address your for loop:

for (int i = 0; i <= firstArray.GetUpperBound(0); i++)
                for (int j = 0; j <= firstArray.GetUpperBound(1); j++)
                    firstArray[i, j] = ??;

I'll let you fill in the stuff for Random yourself (I can't have all the fun!). You were stepping along the array's "diagonal" (really only covering 6 points since it's not a square matrix)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Based on your specification, you'll need to revamp your code a little bit to use a structure. So you'll need it outside of main() like:

struct rainfall_data
{
      int amount;
      string month;
      
       rainfall_data(string monthname){month = monthname;}
       //you can read anything on class constuctors too because they are
         //virtually identical
};

Then you'll need an array of those rainfall_data yearly[12]; I didn't examine your sort too carefully but it looks like it's pretty good. Now you just need to sort based on rainfall.
(see this for some info as to how you should access the members

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

And this:
ComplexInterface theComplex();
is still not right.
nor FileHandling file();

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

ok made the revisions and still getting the "undefined reference to 'complex()'" errors on the complex() lines
and "undefined reference to 'file()'" errors on the file() lines errors attached the new code
sorry to have so many problems I've been hacking away at this code for the better part of a week and am sure im missing stuff i should know also the vectors lecture is next semester so im pulling most of this from my java array list knowledge and crash coursing the internet

There shouldn't be any complex() lines or file() lines (outside of their constructor definitions in their own class files) it should be object.method() across the board.

EDIT: These are still around (in complexinterface.h):

vector<Tenants> complexList();//holds a vector of tenants
	vector<Repairs> repairsList();//holds a vector of repairs

get rid of the ()

Another random thing: tenants.h has vector.h included it should just be <vector>

Demo and file handling still have complex.h

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Wow, more power to you for taking up C++ in only 4 days. I realize this might not be homework for you but it might make us feel better either way if you took a shot at it yourself first. Even a blend of pseudocode (the beginnings of which you have from the assignment) and laying out the code that you do know would be a plus. This way you get to test out what you learned from your class too!

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You're very welcome. :)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Do you really want an array to represent the year and the running time? so leave those as ints. Also, any title over 1 word gets truncated. Why not use a getline for that as well?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

There are a bunch of changes

take off the () these are not methods, these are members
        vector<Tenants> complexList;//holds a vector of tenants
	vector<Repairs> repairsList;//holds a vector of repair

//take off the () on complexList, again not a method
for (int i = 0; i < numberOfUnits; ++i) {
			cout << i+1 << " " <<complexList[i].getTenantName();

//there's a ton more, like in here (I didn't change them)
cout << "Tenant Name: " << complexList()[unitNum].getTenantName() << endl;
	cout << "Unit Number: " << complexList()[unitNum].getUnitNumber() << endl;
	cout << "Balance Due: $" << complexList()[unitNum].getBalanceDue() << endl;
	cout << "Size: " << complexList()[unitNum].getUnitSize() << " BedRooms\n";
	cout << "Number Of Repairs: " << complexList()[unitNum].getAptNumberOfrepairs() << endl;

Do the same for repairslist
There are a couple of spelling errors in Tenants.cpp (repiarlist) which are also causing errors -- on top of that when they are corrected to repairsList, it's not in scope in Tenants.cpp

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I haven't figured out what's up with the error you posted but looking closer at your code, you should probably rename complex.h to something else because that's the name of the old (non-standard) complex number header. It doesn't give an error but there are warnings about it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Two choices this time too, you can put a prototype float average(int a[],int); at the top (above void displayTitle)
and then put your function definition (what I posted above) after the closing brace of main:

int main()
{

}
float average(,)
{


}

or you can skip the prototype and put the whole thing above void displayTitle()

float average(int agearr[],int count)
{

}

void displayTitle()
{

}
int main()
{


}
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster


Writing a scripting language requires a lot of parsing and communication between functions, so I am starting at the ground and learning up.

To do that, I have to know exactly how C/C++ works with strings.

I gotcha. Sounds like a cool project (and automation anything is always nice). I've begun to appreciate the power of using streams to do things but getting it all from the ground up is a great way to learn a ton, so best of luck.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What is the output you are getting currently?

There are a couple of options for a function, one is you can pass in Age[] and I

e.g.,

float average(int agearr[],int count)
{
           float ave
           int sum (over all agearr)
           cast sum to a float
           ave = sum divide by I
           return ave
}

and then call it in main() Average = average(Age,I); or if you preferred you could pass in sum and I and have it do the division for you.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Asking for the sake of curiosity, is there a specific reason you're not using the filestreams and <string>?
for example see this which might (I don't know for sure) have similar insides and can definitely be used in a loop.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You don't need the () when using a default constructor nor do you need them on the object when invoking a method (you do need them on the method call itself)

complex().setRepairPtr(file().getRapairPtr());

should be 
complex.setRepairPtr(file.getRapairPtr());

and your object declaration should be 
Complex complex;

The second part of your question I'm not sure of, but if you are dynamically allocating those objects then you'd need to take care of that in the constructor of the object being called.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

There's a mismatch on your signatures

ShowAll(x, y, z, average, max, min);
vs.
void ShowAll(int x, int y, int z, float average, int min, int max)
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I assume you have more than one row of data in the .dat file? If so, you need to wrap your if statements within your while so that once the data are read in and evaluated you can move on to the next line.
I changed the while loop a little, firstly because there are problems with using eof (do a quick search of threads here for it) but secondly because fails1 isn't defined anywhere in your program.

while(file1>>a)
         {
         	
               	file1>>b;
               	file1>>c;
         

        	if((a+b)>0||(b+c)>0||(c+a)>0)
                {
        	         file2<<"YES\n";}else{file2 <<"NO\n";
                 }

        	if((a+b)==0||(b+c)==0||(c+a)==0)
                {
        	        file2 <<"YES\n";}else{file2 <<"NO\n";
                }

	        if((a+b)<0||(b+c)<0||(c+a)<0)
                {
			file2 <<"YES";}else{file2 <<"NO";
                 }
} //end while

You also have file2.close twice.

I may have missed something but the answer you gave is correct for the numbers that you give -- sum of any 2 is positive, sum of any 2 is not zero, sum of any 2 is not negative.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

end the for loop in line 25

That is incorrect. Notice the OP has statements requiring the use of the loop variable up until 31.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Hi, welcome. What code do you have so far? You should read this.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

See http://www.cplusplus.com/reference/iostream/istream/get/ you'll want the third one down that takes a streamsize (there's an example at the bottom of the page but its got some error checking that you can probably put on hold for the time being).
As far as the two names in one field is concerned -- this may not be the best or most elegant way of doing it, but you could read the names into two temporary variables and then concatenate them into your name array.
I assume you are using char arrays based on an assignment, but if you don't have to use them look into strings instead.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Your brace on line 31 closes off the else paired with the for above it. All of that code is enclosed in a for loop starting on line 21. Placing a } after line 31 but before Average = etc will close off the for loop from line 21. Since you were missing the closing brace, there were are odd number of braces and the last brace in your program (line 44) was being (mistakenly) paired with the one from the for loop on line 34.

As far as the second for loop goes, ask yourself why you are taking I= I-1 in the prior for loop. Because you don't include those records for servicepeople under 18. So if your list was 50 long and you're excluding say 5 people, you'll only have 45 ages. You want your second loop to know this because if you've only written in 45 names, the last 5 slots in the array will contain garbage that you won't want in your final printout.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You need a } right after line 31 in the above code to close off the first for loop. Then they should all balance out.

Also, unrelated to this:

for ( int i = 0 ; i<I; i++ )
    {
        cout << "Age of Personnel" << ( i + 1 ) << "is : "
        << Age[i] << endl ;
       }

Your second for loop should go from something to letter I because you've kept track of the number of ages over 18 in your array, otherwise you'll print junk for the remaining open slots until 50.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Start out with the class declaration. You have a portion of it already written in this post.

class StringSet
{
          private:
                 //Probably want your array here
          public:
                 //Constructor(s)
                 //Your other functions
}; //this might go in a header file if you want to

Then
Stringset::Stringset(String[] mystring)
{
       constructor "stuff" goes here
}

Just take it a step at a time and post back once you have some code.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm not sure because I don't have a main() to test with.

You could just make a few objects that are equal and not equal to test out your operators
e.g.

Date today(12,14,2009);
Date tomorrow(12,15,2009);
Date copyofdate(12,14,2009);
cout <<"today < tomorrow "<< (today < tomorrow)<<endl;
cout << "today == tomorrow "<<(today == tomorrow)<<endl;
cout <<"copyofdate == today "<<(copyofdate == today)<<endl;

(I didn't compile the above so there may be an error or two)

EDIT: Make sure you either put your main at the end of your existing file -- if you put it in its own file, you need to split off your class declaration into a .h file and #include "yourheader.h"

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Turbo C++ is your problem. There's a lot of nonstandard stuff in your program, like stdlib.h is #include <cstdlib>, and your randomize and random functions are non-standard. You also need to qualify all your library function calls (cout, ifstream,ostream, etc) with std:: or have using namespace std; (but not recommended). If you're on Windows, do yourself a favor and grab http://www.mingw.org/ the gcc (and g++) and you'll probably have a virtually identical compiler to your school's (and for free).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

No problem. I'm glad to help. It's great that you went back and reviewed all that material -- it's of great benefit. Definitely post back if you need anything.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I think your output and stuff was closer the first time. As of now your write statements aren't really doing anything (I can't even get them to compile like that and they have the wrong # of arguments). To be honest, I find it much easier to use ifstream and ofstream and use the >> and << operators (just like with cin and cout). Then you could use a string for employee name and all those strcpys live to fight another day. That's just my 0.015 dollars worth.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I had thought about suggesting that too, but OP wasn't doing anything strictly numerical with the data anyway. All that division and modding couldn't be all that much fun... ;)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You were writing to a in the method and then trying to pass empty arr into your print function. So pass a into the print function. Remember the name of the argument that you are passing in in main and the name of the parameter of the function have nothing to do with each other. Once you run the populate function, the array is changed (by pointer) and so when you pass in the same array into print it will receive the values by pointer also.

As far as your random values, you should only have one randomization function, either in the method or in main(). The one in main and the one in the function could come up with different values and then they will conflict. There's still something about that function that it keeps coming up with the same number over and over. I had it earlier that it wasn't doing that I'm trying to isolate it now.
Here's my main() in case that helps (though I used arr, you are fine with using a for both)

int main()
{	
	
	int arr[ARRAY_SIZE] ;
	//srand((unsigned)  time (NULL ) ) ;
	
	int numberOfElementsToStore = populateArray(arr) ;
	printArray(arr,numberOfElementsToStore) ;

    
     return 0;
}

EDIT: Ok, this is one of those oddities that I'm sure someone had explained to me more than once but I just don't get it. So I took srand out of main() (housekeeping more than anything) but I put back in a cout in populate() where …

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

How in the world am I supposed to "get" the first fraction to multiply it with the second one???

You have it. Read up in your text about the *this pointer. You've formed this object and now it has a reference to itself:
this->numerator and this->denominator are the values for the current object (since the object and any other objects of the class can "see" its private members). So in your frac1s that you are passing in, the numerator and denominator will be visible (but invisible to other classes since they are private.

So for the addition operator for example, declare a new fraction local to that block, Fraction fracresult; or something:
fracresult.numerator = (this->numerator x denominator of frac1) + (numerator of frac1xthis->denominator); (standard formula for adding two fractions - now the denominator will be the product of the denominators and set equal to fracresult.numerator)
The reason you need the -> is that the object has a reference to *this, so you need to dereference and . to access the method and arrow is a shortcut for that.

EDIT: Well there's an outpouring for you. What he said definitely works too (with using the constructor) -- though you shouldn't need an accessor (getter) between two objects of the same class, but it couldn't hurt to add one (though I think you said you are limited by the assigned header file) for other classes to interact with.

Agni commented: my bad, thanks for correcting :) ... +2
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You only need to call srand() once per program.

That was my bad, I thought that it was helping but I'd also taken the cast off of the given "random function" (10+25*etc)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I put another srand((unsigned)time(NULL)); into the body of the populateArray() function and it seems to work now.
and took off the (int) cast of int numberOfElementsToStore = (int)( 10 + 25 * ((double) rand( ) / (double) RAND_MAX )) ;

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I interpreted your assignment slightly differently:

int populateArray(int a[] )
{
	int numberOfElementsToStore = (int)( 10  + 25 * ((double) rand( ) / (double) RAND_MAX )) ;
	int i = 0 ;
	for (int i = 0; i < numberOfElementsToStore; i++)
	{
		a[i] = rand() % 100;
	}

	return numberOfElementsToStore;
}
	
int printArray(int arr[],int numelements)
{
	int i = 0 ;
	for (int i = 0; i < numelements; i++)
	{
		if ((i+1) % 10 == 0)
			cout << fixed << setw(6) <<arr[i] << " " << endl ;
		else
			cout << fixed << setw(6) << arr[i] << " " ;
	}

	return i ;
}

with the random function determining the number of elements in the array. You can play around with the rand % 50 to get the range of numbers that you need. I had to rename some things and change some of your doubles to ints (again can be adjusted accordingly for your assignment).

Also, please try to avoid global variables... there wasn't much standing in the way of their being defined in main and passed in.

EDIT: There's a problem with the number of values generated it seems to be constant. I did need to take the double out from the front of srand() in main... that helped with the values but not the number of them.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Change student_number to an array of char. Employ the transformation first = (int)(student_number[0]-'0'); to get the first character back to a digit (you don't need to declare first as first[0] as an array with zero elements is just a regular variable). You'll need to change your scanf also to reflect these changes.

Also, please use the code tags (code) your code goes between these (/code) next time.