redrum237 0 Newbie Poster

I have a student report system, which runs several queries.

one query is to:
List all payments made by each student, alphabetically by enrolment number, and show amount paid and outstanding.

My program works, and what i get displayed is the student number(foreign key), the amount paid, and the amount outstanding. I also want to display the payment type, but cant seem to load this into my program. here is the data that i have used, and my code is also listed below. any advice would be great. thanks

Payment (foreign key, amount, type [blank implies cash])
11 50
12 25 4543 2323 2321
12 25 Barclays
13 100
14 100
15 50 4545 6343 4342
15 25 Midland
16 100
17 100
18 100
19 100
20 25 4546 3432 3211
21 75
22 100 Lloyds
23 100

void University::displayStudentPayments()
{
	list<string> outlist;

	int cost=0;
	int paid=0;
	int diff=0;

	char op[50]="";
	
	list<Student>::iterator ptr;
	ptr = Students.begin();
	while(ptr!=Students.end())
	{

		//for each ptr student count total and remaining

		//total
		list<Mark>::iterator ptr1;
		ptr1 = MarkList.begin();

		while(ptr1!=MarkList.end())
		{
			if(!strcmpi(ptr->getidentifier().c_str(),ptr1->getst().c_str()))
				cost=cost+100;

			ptr1++;						
		}


		list<Payment>::iterator ptr2;
		ptr2 = Payments.begin();

		while(ptr2!=Payments.end())
		{
			
			if(!strcmpi(ptr->getidentifier().c_str(),ptr2->getst().c_str()))
				paid=paid+atoi(ptr2->getamount().c_str());

			ptr2++;		
	
		}

		diff = cost-paid;
		

		char temp[50]="";
		strcat(op, ptr->getidentifier().c_str());
		strcat(op, "	");
		strcat(op, itoa(paid ,temp,10));
		strcat(op, "	");
		strcat(op, itoa(diff,temp,10));
		strcat(op, "	");

		outlist.push_back((string)op);
		paid=0;
		diff=0;
		cost=0;

		ptr++;
		strcpy(op,"");

	}
	outlist.sort(compare_nocase);
	list<string>::iterator it;

	cout<<endl<<"Student	Paid	Oustanding "<<endl;

	for (it=outlist.begin(); it!=outlist.end(); ++it)
		 cout<<*it<<endl;
	cout<<endl;



}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.