How to resolve the algorithm Top rank per group step by step in the Run BASIC programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Top rank per group step by step in the Run BASIC programming language
Table of Contents
Problem Statement
Find the top N salaries in each department, where N is provided as a parameter. Use this data as a formatted internal data structure (adapt it to your language-native idioms, rather than parse at runtime), or identify your external data source:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Top rank per group step by step in the Run BASIC programming language
Source code in the run programming language
perSal$ = "Tyler Bennett,E10297,32000,D101
John Rappl,E21437,47000,D050;
George Woltman,E00127,53500,D101
Adam Smith,E63535,18000,D202;
Claire Buckman,E39876,27800,D202
David McClellan,E04242,41500,D101
Rich Holcomb,E01234,49500,D202
Nathan Adams,E41298,21900,D050
Richard Potter,E43128,15900,D101
David Motsinger,E27002,19250,D202
Tim Sampair,E03033,27000,D101
Kim Arlich,E10001,57000,D190
Timothy Grove,E16398,29900,D190"
while word$(perSal$,n+1,chr$(13)) <> "" : n = n + 1 : wend ' get count of employees
dim depSal$(n)
for i = 1 to n
depSal$(i) = word$(perSal$,i,chr$(13))
next i
sw = 1
while sw = 1
sw = 0
for i = 1 to n -1
if word$(depSal$(i),4,",")+word$(depSal$(i),3,",") > word$(depSal$(i+1),4,",")+word$(depSal$(i+1),3,",") then
temp$ = depSal$(i)
depSal$(i) = depSal$(i+1)
depSal$(i+1) = temp$
sw = 1
end if
next i
wend
print "Employee Name";chr$(9);"ID";chr$(9);"Salary"
for i = 1 to n
if dep$ <> word$(depSal$(i),4,",") then
dep$ = word$(depSal$(i),4,",")
print : print"Department:";dep$
end if
print word$(depSal$(i),1,",");chr$(9);word$(depSal$(i),2,",");chr$(9);word$(depSal$(i),3,",")
next i
You may also check:How to resolve the algorithm Hunt the Wumpus step by step in the SparForte programming language
You may also check:How to resolve the algorithm Superellipse step by step in the Wren programming language
You may also check:How to resolve the algorithm Literals/Floating point step by step in the Dyalect programming language
You may also check:How to resolve the algorithm Sum of squares step by step in the APL programming language
You may also check:How to resolve the algorithm Runtime evaluation step by step in the OxygenBasic programming language