jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Please show us what you have so far.
Take a look at this http://www.daniweb.com/forums/announcement8-2.html

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Combine this:
http://en.wikipedia.org/wiki/Gaussian_elimination#Pseudocode

And this:
http://en.wikipedia.org/wiki/Pivoting#Scaled_pivoting

I strongly suggest that you sit down with pencil and paper and work out an example step by step, writing down what you are doing (e.g., I'm multiplying row 1 by a factor of a and added it to row 2, etc. etc. Then translate that into what the program will have to do (into your own pseudocode) and into actual code.

The reason people are reticent to help you (or anyone in your position really) is that you have shown no effort. There are dozens of examples online that go into quite a bit of detail. To search and then say you found "nothing" on this topic is absurd.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Try popping in a %20 for the space
"C:\\Program%20Files\\Microsoft\\Exchange%20Server\\Bin\\eseutil.exe\"
Having the path in quotation marks should take care of that but it seems like in your other example it's truncating based on the space.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

a^b is not a to the b power, it is (a XOR b)

int power = pow(a,b); will work (of your functions and variables and the cmath functions many have the same name which can be confusing at best

P.S. Please use code tags //your code here next time to make it easier to read and maintain the formatting

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Just into 3 groups, cutting off the count at 7? Just make 3 arrays that are 1/3 the size of the big array (if it doesn't divide evenly you'd have to make a 4th array) and copy the ints over element by element.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
i = 0;
while (fin >> x[i] ) 
{
       i++;
       if( i ==n)   //less than elegant but it's off by 1 if you && it in
            break; //to the loop condition
       
}

What you had was going out of bounds over and over --->fin >> x[n]; (n=20 is the last element of the array)

If you don't know how many data you will be reading in you are better off using a STL vector. They expand in capacity as the need arises.

Otherwise you could either get the total number of points from the user and use int * myarr = new int[numberuserentered]; Failing that you can set an upper limit MAX_SIZE and declare int arr[MAX_SIZE];

I don't quite understand what you are asking on the 2nd question.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Write out the class declaration (i.e., what you would put in the header file, class fractionType{//your declarations here }; ) and pinpoint specific areas that are giving you trouble. Try it on your own first, then search around in this forum for "rational class","fraction class", "operator overloading fraction."

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Did you read the post that I linked to in post #4? There are 3-4 non-standard ways which are system dependent (the Win32 solution being among those). Something like this http://pdcurses.sourceforge.net/ would be an option but there's no guarantee of portability and you'd have to learn a library.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Check this out for those functions: http://msdn.microsoft.com/en-us/library/ms682073(VS.85).aspx (or google any of them with "Win32 functionname" And look up any of the Win32 API tutorials to get an idea about what it can do (goes way beyond just the console).

In terms of the placement of the function call, I think it makes the most sense to do it there, that way you get the clean screen the first time as well. It's just a matter of taste and practicality, you wouldn't want to clear the screen in the middle of the input and you wouldn't want to wait through one cycle before doing it for the first time.

The important thing to glean from this is that there is no command in standard C++ which readily accomplishes this task. So, if you had a user on Linux (and probably Mac, though I don't know for sure) this program wouldn't work for them because it uses the Windows API. Lerner's is a fairly portable solution but puts the cursor in a different spot.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You could have left a " off somewhere. I got a similar error to yours when I did that. Honestly I'm not sure...

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I was toying with that idea too. I mean there's a simple solution, not a good solution, but for the purposes of this project (Wiser Ones please avert your eyes for a moment) he/she could probably get away with the system call. That's why I referred him to the other thread so he/she could make an informed decision.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Heh..I did about the same thing before, but it didn't work. Must have been an error that I didn't see.

This however does work. Thanks.

No prob. Do you remember what kind of errors it was giving you? Sometimes you miss one brace or something....it ends up befuddling everything.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You're going to have to compile it as a Windows console application. If you are using VC++ you can just select Win32 console after you create a new project. If not which system are you using?
Keep your includes and add his (though change <stdio.h> to <cstdio>).
Put a prototype for his function at the top of your code and put his function after your main().
Then move your banner ("CASH RECEIPT PROGRAM") into your while loop and call his function before you display that.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Something like this: std::string answers[3][2] = {{"12","12"}, {"12","12"},{"12","12"}};

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I would add another dimension to your array, e.g.:

char answers2[5][4][2] = {{{'1','2'},{'1','2'},{'1','2'},{'1','2'}},{{'1','2'},{'1','2'},{'1','2'},{'1','2'}},{{'1','2'},{'1','2'},{'1','2'},{'1','2'}},{{'1','2'},{'1','2'},{'1','2'},{'1','2'}},{{'1','2'},{'1','2'},{'1','2'},{'1','2'}}};

(has all 12s but you get the idea)
or you could use an array of strings to accomplish the same thing (leave it as 2D).
You have a '10' in your array which isn't a char.

restrictment commented: Yeah, very helpful +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm sure that there's some "pull the ripcord and the whole thing falls into a nice answer" approach, but I would just convert the base 8 to base 10 and make some guesses (e.g., you know it's not base 8) cause the two would be equal. That should give you more than enough to go on.

EDIT: Okay, I'm not going to do your homework for you. There are exactly 18 gazillion (base 10) websites out there that cover this stuff. I'd be willing to bet that going from base 3 to base 9 is similar to going from base 2 to base 8 ;) (and not unlike going from 2 to 16).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

See this: http://www.velocityreviews.com/forums/t291617-std-cout-and-null-character-pointer.html (scroll down to post #6). I was looking for the reference in the standard here but I couldn't find it directly. It seems that passing the null pointer to cout causes the badbit to be set and the output stream invalidated. So that bit would need to be cleared before any further output could go through.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

See my edit above. If not you're going to have to go through the strings character by character until they don't match, decide which one is greater, and then swap the one that's greater towards the end of the array.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

See http://www.cplusplus.com/reference/clibrary/cstring/strcmp/ for strcmp. You need to include <cstring> and your strings you are comparing need to be cstrings (so like the char * variety). You can get strings of this format from your C++ strings by using the c_str() method of any string object mystring.c_str() .

EDIT: You can also use the < , > , >=,<= operators with the C++ strings http://www.cplusplus.com/reference/string/operators/

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Try going to a prompt and compiling it as g++ exercise9.4.cpp exercise9.4main.cpp -o ex94 substitute your own filenames and exe file name. Somehow I think your project in C::B is not set up correctly (I don't use it so I don't know how to remedy it). You may be trying to compile your main.cpp first and it doesn't have the other code to link in.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I just want to ask for comparison's sake, but what compiler are you using?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I am able to get it to compile, minus a total variable that appears out of nowhere and some cin's that had the << operator instead of the >> (I guess I caught your code before you changed it). It was balking about the signature of the setSales function not matching but that resolved. What is the error you are getting now? It could have to do with your namespaces and needing a using statement in main but I didn't test that.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I see. It works now, thanks.

So, whenever I ask a user a question that requires a single variable (like 'Y', or '123'...) I have to use a cin.ignore before using a getline to ignore that \n?

There are other situations in which junk can get stuck in the buffer. At the top of the C++ forum there's a sticky article on flushing the streams, that'll give you some idea of the different situations. 123 isn't a single character, it's a string. I just meant that when cin is expecting one char (as that's all that will fit) and you hit enter after, that's really 2 characters, so the second one sticks around.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Put a cin.ignore(); before each of your getline statements (and get rid of the extra cin for songName). That will get rid of the extra \n character from when you press enter for your cin>>answer; prompt (since answer is only expecting 1 character, the \n is left in the buffer and fouls up your getline). I'm sure you put them in there for testing other options but you don't need to redeclare albumName, etc in this function. In testing this, I again put an extra PrintLibrary() call after I called UpdateRecord(); instead of passing in the ofstream directly.

MrJNV commented: Damn helpful. +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Could you move your banner into the do-while loop:

do{
      cout<<"--------------------------------------------------------------------------------";
      cout<<"\t\t\t\tCASH RECEIPT PROGRAM"<<endl;
      cout<<"--------------------------------------------------------------------------------";
      cout<<endl;

  cout<<"Enter the Product ID ?:";
        cin>>product[i].id;

etc.

that way you get the header each time.

Also, just a minor thing, but your variable total (towards the end on line 131) should be a double instead of an int.

EDIT: Are you asking about clearing the screen completely in between? I'm really sorry that I misunderstood. For that you should see this thread http://www.daniweb.com/forums/thread76934.html which goes through the pluses and minuses of using different methods.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You shouldn't have to clear it out, in fact you want to save it for your totaling and output at the end. When you are incrementing i you are getting the next struct from your array when the flow comes back to the top of the while loop. Maybe I'm misunderstanding what you are saying...

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Nezachem is right. I was starting to post before and it went into the vortex. I was asking about your "lib.h" so I could compile the code, but I assume that it has your #includes in it. From your code it seems like you are missing the fact that (*object).memberfunction() is equivalent to object->memberfunction(). You also were setting your strcmp results = 1 rather than ==1.

Here are some changes I made to one of your if statements which can be easily applied to the other

if( strcmp( (newMember->person->getFullName()).c_str() ,
        (newPerson->getFullName()).c_str() ) == 1 ){        
       temp->person = newMember->person;           
        newMember->person = newPerson; 
  
etc.
}

I don't know if it will work for you as I didn't have main to test it with.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you're going to try firstPerson's way (which might be for the best at this point, I agree) you shouldn't select "empty project" as it will not set some options that are important.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Try File/Close Solution, accept any changes, and reopen it again

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Try Ctrl-Alt-F7 or Rebuild from the Build menu.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Check out the partial keyword:http://msdn.microsoft.com/en-us/library/wa80x488.aspx I think it's exactly what you need.

ddanbe commented: Good thinking! +6
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Firstly, please use code tags the next time: //code here
It makes it much easier to read and maintains the indentation properly.

So first thing is get rid of the return main() statement. It doesn't do anything. When you complete this while loop you're back in main anyway. There's also no need for the ; after the while. Get rid of the else etc as there's no if to that else (except leave the return 0; where it is at the end of main() )

Now at the end of the while loop you are getting input from the user in the variable Repeat. What you should do is eliminate your intermediate variable and use this Repeat value directly as the test for the while loop. So, change the while to while (Repeat =='y') (single quotes because it's a character). Now, so when your program gets to the while loop for the first time, what is Repeat equal to? Not 'y', so your loop won't run. But go back up to your declaration for Repeat and set Repeat ='y';
Now when you press n (or any other character except lowercase y) the loop test at the top will fail and you will be out of the while loop. If you want to go back and add 'Y' to your yes answers later it's not difficult.

There are a couple of other issues in your function. Make the variables in the body of the function floats because you're going …

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You're either going to have to be much more specific regarding the aspects of the problem that you are researching or post your code (preferably both).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I made some changes, commented below:

void DelRecord(MyLibrary Library[])  //instead of passing in an output file, just use the 
                                                       //PrintLibrary up above
{
	int i;	
	//MyLibrary songInfo[MAX_SIZE];  don't need to redeclare this here	
	
	cout << "Choose number the corresponds to record you would like to delete." << endl;
	cin >> i;
	i--; //convert users entry into zero-based index
	while(i <MAX_SIZE-1) //since you are moving i+1 to i
	{
		
		Library[i] = Library[i + 1];
		i++;
	}
	
}
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Anytime you are passing in (type a[]) to a method the call is converted into (type *a) where the array is passed in by pointer. I don't believe there is much of a workaround. If you need your original array intact, copy it memberwise into another array and keep that in main().

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm not absolutely clear on what you are trying to do with the atoi on that line 39. toUpper only works with one character at a time so you'd have to go through each element. The errors you pasted in at the top don't seem to have anything to do with these that you marked in the code, you may need an additional layer of dereferencing since your struct member is a pointer to a class, but I am not positive of that.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Thanks for all your time PP!

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

For a small scale project (i.e. 1 file) you can certainly get away with popping your function definition in its entirety before main(). When dealing with library functions, prototypes are essential because you don't have direct access to the original code for the most part.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Also, I forgot to say in my first post that the ampersand should be included in your function definition as well.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Though check this out (it's for C) http://code.google.com/p/nativeclient/
(I originally heard about it from here) so others have had the same idea.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Why do you have an extra set of parentheses on the end of your function prototype? Get rid of those and put a semicolon at the end.

Also, you probably want to pass in ifstream by reference:
void a(ifstream & b) in your prototype, nothing extra required in the function call itself.

Thumb2 commented: Straight to the solution +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I had to look this up so I'm not much good on further questions :) String ^ kpath = gcnew String(argv[1]); It makes sense to me but I don't have much experience with the CLI syntax.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Actually I had tried that a few months ago but I tried it again to make sure. Still no dice (of course it looks good going through start up but one of the last things that pops up is that warning). I'd be just as inclined to ignore it as I did before but I just wanted to see if it was a known problem. Kaspersky reports in as being alive and well from its own control panel. They haven't sent out an engine patch in a little while maybe this problem will be cured with the next one.

Thanks again for all your help.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

In main, I called PrintLibrary twice once before and once after the addition of the albums, I used a second outfile rather than trying to append with the proper numbering.

int main()
{
	ifstream inFile;
	ofstream outFile;

	inFile.open("MySongLibrary.txt");
	outFile.open("OrganizedLibrary.txt");
	ofstream out2("OrganizedLibraryadded.txt");
	MyLibrary songInfo[MAX_SIZE];

	GetLibrary(inFile, songInfo);
	PrintLibrary(outFile, songInfo);
	//PrintToScreen(outFile, songInfo);
	AddRecord(outFile, songInfo);
	//PrintToScreen(outFile,songInfo);
	PrintLibrary(out2,songInfo);

	inFile.close(); 
	outFile.close(); 

	return 0;


}

Here is a modified version of the method

void AddRecord(ofstream& outFile, MyLibrary Library[])
{
	for(int i =4 /*(MODIFY FOR NUM OF RECORDS PULLED IN)*/; i <MAX_SIZE ; i++)
	{ //if there were 50 records already, it would be #0 to #49 so start with 50

		string genre;
		cout << "Enter Album Name" << endl;
		getline(cin, Library[i].albumName);
		cout << "Enter Song Name" << endl;
		getline(cin, Library[i].songName);
		cout <<"Enter Artist Name"<<endl; //you had forgotten this 
                                                                         //one in this method
		getline(cin, Library[i].artistName);
		cout << "Enter Play Time" << endl;
		getline(cin, Library[i].playTime);
		cout << "Enter Genre" << endl;
		getline(cin, genre);
		
			if(genre == "Rock")
				Library[i].genre = ROCK;
			else if(genre == "Alternative")
				Library[i].genre = ALTERNATIVE;
			else if(genre == "Classical")
				Library[i].genre = CLASSICAL;
			else if(genre == "Soundtrack")
				Library[i].genre = SOUNDTRACK;
			else if(genre == "Children")
				Library[i].genre = CHILDREN;
			else if(genre == "Other")
				Library[i].genre = OTHER;
			else
				Library[i].genre = OTHER; //or reject bad user input
	
		
		cout << "Enter Album Producer" << endl;
		getline(cin,Library[i].albumProducer);
	}
	

}

I'd stick with the getlines to be consistent. I was having some trouble with the cin >> which could have been alleviated with cin.ignore() but I didn't bother.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

No problem. Post back whenever!

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Check to make sure the output isn't just scrolling off the screen. If you're running it from the command prompt, just do myprogramname > screenout.txt and you'll get an output file.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Here's what I ran

#include<iostream>
#include<iomanip>
#include<string>
#include<fstream>

using namespace std;

enum songCategory {ROCK = 0, ALTERNATIVE = 1, CLASSICAL = 2, SOUNDTRACK= 3, CHILDREN=4, OTHER=5};
struct MyLibrary
{
	string albumName;
	string songName;
	string artistName;
	string playTime;
	songCategory genre;
	string albumProducer;
};

void GetLibrary(ifstream& inFile, MyLibrary Library[]);
void PrintLibrary(ofstream& outFile, MyLibrary Library[]);
void PrintToScreen(MyLibrary Library[]);
void AddRecord(ofstream& outFile, MyLibrary Library[]);

const int MAX_SIZE = 200;



int main()
{
	ifstream inFile;
	ofstream outFile;

	inFile.open("MySongLibrary.txt");
	outFile.open("OrganizedLibrary.txt");

	MyLibrary songInfo[MAX_SIZE];

	GetLibrary(inFile, songInfo);
	PrintLibrary(outFile, songInfo);
	PrintToScreen(songInfo);
	//AddRecord(outFile, songInfo);
	


	inFile.close(); 
	outFile.close(); 

	return 0;


}

void GetLibrary(ifstream& inFile, MyLibrary Library[])
{
	for(int i = 0; i < MAX_SIZE; i++)
	{
		string category;

		getline(inFile, Library[i].albumName);
		getline(inFile, Library[i].songName);
		getline(inFile, Library[i].artistName);
		getline(inFile, Library[i].playTime);
		//getline(inFile, Library[i].genre);
		//string category;
		getline(inFile, category);
			if(category == "ROCK")
				Library[i].genre = ROCK;
			else if(category == "ALTERNATIVE")
				Library[i].genre = ALTERNATIVE;
			else if(category == "CLASSICAL")
				Library[i].genre = CLASSICAL;
			else if(category == "SOUNDTRACK")
				Library[i].genre = SOUNDTRACK;
			else if(category == "CHILDREN")
				Library[i].genre = CHILDREN;
			else if(category == "OTHER")
				Library[i].genre = OTHER;
		
		getline(inFile, Library[i].albumProducer);
	}
}


void PrintLibrary(ofstream& outFile, MyLibrary Library[])
{	
	for(int i = 0; i < MAX_SIZE; i++)
	{
		outFile << right << setw(3) << i + 1 << ") ";
		outFile << Library[i].albumName << endl;
		outFile << "     " << Library[i].songName << endl;
		outFile << "     " << Library[i].artistName << endl;
		outFile << "     " << Library[i].playTime << endl;
		outFile << "     " << Library[i].genre << endl;		
		outFile << "     " << Library[i].albumProducer << endl << endl;
	}
}

void PrintToScreen(MyLibrary Library[])
{
	for(int i = 0; i …
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

...how? Can you copy that code and paste it here?

See my edit on the previous post.
You also have your print to screen method starting from 9 for some reason. The "junk" you are seeing when this is output is due to printing uninitialized variables, which will go away once you feed it the whole songset (or keep track of the number of structs written with a counter and send that number into your printing functions as an upper limit)

MrJNV commented: Helped a major issue +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Here's what I got (changing one to childrens and one to other to test it):

1) Queen - Greatest Hits
    We Will Rock You
    Queen
    204
    0
    123 Studios

 2) Queen - Greatest Hits
    We Are the Champions
    Queen
    303
    4
    123 Studios

 3) Queen - Greatest Hits
    Another One Bites the Dust
    Queen
    338
    5
    123 Studios

EDIT: I should say that was my output file, when you posted the screen printing method it was commented out.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Your text file has "Rock" but your if statements are testing for "ROCK" so either you have to change the if statement or convert your input to upper case (leave your enum case the same).