I am currently trying to write a program which provides a quarterly overview of the amount of money that a user defined number of salesmen has made for a whole year.
Here is the code I have at the moment:
program Verkopers;
var month, day, sellernr:array[0..99] of integer;
sale:array[0..99] of real;
count, num: integer;
begin
num := 0;
writeln('Enter seller number. To stop enter "0"');
readln(sellernr[num] );
while (sellernr[num] <> 0) do
begin
writeln('Enter date in DD MM format');
readln(day[num] , month[num] );
writeln('Enter sale amount');
readln(sale[num] );
num := num + 1;
writeln('');
writeln('Enter seller number. To stop enter "0"');
readln(sellernr[num] );
end;
writeln('Seller Nr.':10, 'Date':14, 'Amount':16);
for count := 0 to num-1 do
begin
writeln(sellernr[count], day[count]:20,'/',month[count], sale[count]:14:2);
end;
writeln('');
writeln('ENTER to stop');
readln();
end.
So as you see, the program asks for the seller number, then date in DD MM format and then the amount of the sale.
It the prints out to the screen.
What I have to do next is provide the per quarter overview. I have to take each seller number which the user has defined in the array sellernr and add up the total sales per quarter.
That's where I have a problem. How do I take the values that are stored in the array and recognise when they are equal (ie when sellernr[x] and sellernr[y] are the same)
Say the seller numbers the user inputs are 10, 50, 100. I must then take only the array elements which correspond to, first, 10 and print out, for example:
Seller Quarter1 Quarter2 Quarter3 Quarter4
10 $360.32 $567.21 $988.27 $1023.66
How can I take sellernr[x] which correspond to a particular user-defined value?