Sie sind auf Seite 1von 5

Problem definition

Create a program that accepts the salesperson names, number of games sold,
revenue generated by game sales, and calculate and print the commission for a
salesperson along with the salesperson name and their revenue generated, also
calculate the total revenue generated, total commission for the day and the value of
the highest commission obtained.

Input, Processing and Output table


INPUT
Salesperson names;
number of games sold;
revenue generated;
commission

PROCESSING
For each salesperson
calculate their
commission; calculate the
total revenue generated,
total commission for the
day, calculate the highest
commission obtained

Identifier listing
Variables
numgames array; integer
salepersonname array; string
revenuegen array; real
commission real
YN character
a, b integer
highestcommission real
Totalrevenue real
Totalcommission real
Constants
maxcomper=0.15
mincomper=0.10

OUTPUT
Salesperson name;
revenue generated;
commission generated;
total revenue for the day;
total commission for the
day; highest commission
for the day

START
a0
b0
Maxcommission0
PRINT Do you want to enter a record for a salesperson? {Y/N}
YN readkey
WHILE (Y/N)y) and (a<=99) DO
BEGIN
a (a+1)
PRINT Enter the name of salesperson
READ salepersonname [a]
PRINT Enter the number of games that this person sold
READ numgames [a]
PRINT Enter the revenue earned by this salesperson
READ revenuegen[a]
IF (numgames [a]>= 15) THEN
BEGIN
commission[a] (revenuegen[a] * maxcomper)
END
ELSE
BEGIN
commission[a](revenuegen[a] * mincomper)
END
ENDIF
IF (commission[a] >= maxcommission) THEN
BEGIN
maxcommissioncommission[a]
END
ENDIF
PRINT Do you want to enter a record for a salesperson? {Y/N}
YNreadkey
END
FOR (b) 1 to a DO
BEGIN
totalrevenue (totalrevenue + revenuegen[b])
totalcommission (totalcommission + commission[b])
END
ENDFOR
b1
FOR (b)1 to a DO
BEGIN
PRINT Salesperson, salepersonname [b]
PRINT Number of games sold, numgames [b]
PRINT Revenue that earned $, revenuegen[b]
PRINT Commission earned $, commission[b]
END
ENDFOR
PRINT Total Revenue $, totalrevenue
PRINT Total Commission $, totalcommission
PRINT Highest commission received by salepersonname [b], , was paid $, maxcommission, commission.
END

Pascal Algorithm
program generator;
uses crt;
var
numgames: Array [1..100] of integer;
salepersonname: Array [1..100] of string;
revenuegen: Array [1..100] of real;
commission: Array [1..100] of real;
YN: char;
a, b :integer;
highestcommission, totalcommission, totalrevenue:real;
const
maxcomper=0.15;
mincomper=0.10;
begin
a:=0;
b:=0;
highestcommission:=0;
write('Do you want to enter a record for a salesperson?');
YN:=readkey;
if(lowercase(YN)<>'y') then
begin;
writeln('no data entered. press any key to close');
exit;
end;
while(lowercase(YN)='y')and(a<=99) do
begin;
a:=(a+1);
write('Please enter the name of the salesperson: ');
readln(salepersonname[a]);
write('Please enter the number of games that this person sold: ');
readln(numgames[a]);
write('Please enter the revenue earned by this salesperson: ');
readln(revenuegen[a]);
if(numgames[a]>=15)then
commission[a]:=(revenuegen[a]*maxcomper)
else
commission[a]:=(revenuegen[a]*mincomper);
if(commission[a]>=highestcommission)then
begin;

highestcommission:=commission[a];
end;
writeln ('Do you want to enter a record for another salesperson?');
YN:=readkey;
end;
for(b):= 1 to a do
begin;
totalrevenue:=(totalrevenue + revenuegen[b]);
totalcommission:=(totalcommission + commission[b]);
end;
b:=1;
clrscr;
writeln('----------');
writeln('day report');
writeln('----------');
for(b):= 1 to a do
begin;
writeln('----------');
writeln('salesperson: ',salepersonname[b]);
writeln('number of games sold ',numgames[b]);
writeln('revenue that earned: $',revenuegen[b]:2:2);
writeln('commission earned: $',commission[b]:2:2);
end;
writeln('----------');
writeln('total revenue generated: $',totalrevenue:2:2,'.');
writeln('total commission: $',totalcommission:2:2,'.');
writeln('highest commission was received by ',salepersonname[a],', was paid $',highestcommission:2:2,'
commission.');
writeln('----------');
writeln('press enter to close');
readln;
end.

Rishi loorkhoor
Naparima College
5A
IT SBA
PROGRAMMING

Das könnte Ihnen auch gefallen