






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The creation of an employee object in visual basic.net, using an arraylist to store the objects and determine weekly salaries based on regular and overtime hours. Instructions for setting up the form, creating the employee class, and implementing the weeklysalary, regulartime, and overtime functions.
Typology: Exams
1 / 10
This page cannot be seen from the preview
Don't miss anything!







0
CGS 2421 Visual Basic.NET Summer ZObg ,
As a pay roll manager, you determine that ,you need a^ quick way,^ outside^ of^
-excel, to
hours they work in^ a^ week.
How it works:
Each employee is represented by'ai"Employee object.^ The program^ you^ will^ build^ uses^ an arraylist (not^ array) to contain Employee^ objects^ to^ which^ the^ attributes^ df^ first^ name, last name and pay^ level^ are,ascri6ed.^ This^ object^ class^ will^ have^ a^ PI/BLIC^ function^ that
are Regular Time (in^ our^ case,^ hours^0 thru^ 40)^ and^ Oier^ Time (any work^ beyond 40 hours)..^
Public Sub New.:. 'ci:reai,e:;1ew..""t,1,r."^ c7r1ci.ts:s-(Tls ilct:.ixiei:c:r'.g
Pubtic Function WeeklySalary (ByVal,^ hours.^ 'hs (^) Double)
Private Function RegufarTime(ByVat regularhours As^ Double)
Private Function Overtime(ByVa1 overtimehours As^ Double) EndClass,,*r,r
r (^) r ',
the employee names. Output^ oT^ hours worked is^ in^ the^ fo'rm^ of^ a^ messagebox'. Pay rates for given pay^ levels are as follows:. Level ular^ Overtime Elecutive (^) S ss.2s s 82.87s Mid-Level Manager 's,-^ 37.1.5^ S ss.72s Neril Hire (^) s _ 2250 $ gt.zso HINT:'Notice that overtime'is EXACTLY 1.5 times regular tim-e.
-t' ' 'The ; GUI has I groupbbx,4 labels, 3 textbox6s, 2 buttons,^1 combobox,^ and^ one^ listview.
This program.will uie I^ arraylist^ (not^ array)^ as^ its^ data structure.^ This anaylist^ will store^ :
rUser (^) will have put (^) in a first and last"hame asiwell haie selected apay ldvel'(there will be 'lNO (^) ERROR CHECKING for this)."This info will be used to create a new "Employee" object, which will be added^ fo^ the"employdelist arraylist^ (see^ code giv'en).^ The^ listview must then be updated for'the^ new addition.^ Both textboxes^ will^ be^ cleared, the combobox will be reset and tbxFirstName_will be foc-used upon.
i
CODE GIVENi
Private Sub btnAdd-C1ick... Dim newEmployee^ As^ Employee^ : Dim fName, 1Name, leriel^ As^ String l l' i fName^ =^ tbxFirstName.Text. fuame (^) = tbxlastName.Text^ *"
'::. !;nd Sul)
Private Sub^ btnReport-Click... Dim enteredHours As^ Double^ i
1l_^ I^ Dim^ currentEmployee^ As^ Employee^ i
currentEmployee (^) = ...
t
. End^ ri
t"
Ir
frtr uhe.-,r--: nirren rrarz lF,'e-l ::tr-.1 lennnrr-pqr-Jr.rFs!!! f.)-al^ rFrlt:l;r*-ii.rrrv!r'q+!+! naV.
End Class
o Be sure to adherdto every requirement for the Add button (under^ Form Controls).
o There is no error checking for nonsense inputs or an invalid selected index in the listview.
o Pay careful attention to the^ messagebox^ generated^ by^ the^ report button^ (see walkthrough). Be sure that the formats match up, and notice that the dollar output is formatted. Don't worry^ about using^ floor^ or^ ceiling^ on this^ value.
o Your program MUST use the object class given; WeeklySalary MUST be public, and calls on RegularTime and OverTime, which MUST be private.
o Be sure to set the listview so that when clicked, an entire row is selected and not just^ an
when you^ click outside of the listview. The selected index remains.
PROGRAM WALKTHROUGH: Your program^ should behave exactly as follows!
i":F,'fttlvl'l:yb:9'_ a-
t? r ,i First^ Hame,^ .i--^
" j\
. Last^ lJame. '_ Level: (^) Select Pal,Level
'Add (^) Employee
l'dage TCeekly Hours :
**16@,rt,i.,qt$f&-iqs
L_* (^) *
Step 1: Form loads.
Employee|nformation (^) |,--,,I LEC! name ilI$ f{Ame t (^) Firut tl"** (^) : (^) i-- | o'e,i"n conan
: (^) Laet Name:^ I^ Leno^ Jay
Select Pd,r Gvd
i
lVeek[ Haurs : Repsrt'Ihrs WEek's Salary t, t I
employee's pay level. Again, focus returns to First Name textbox.
I I I LenC' Jd)'
Emdoyee lnfaniietisn^ i | t"ut""'''^ tlu"^ Rrgt^ FJame Fir$ Name.:. I O"Bilan fsnan Last l,iame : Level :
I .tI , I I I I' !, I i
Select Pay Level^ v
Fdd Emplsyge
lVage l$'eekl'l (^) Hguru : (^) ,€
-{*f
*+
f; Emplsree lnformatian (^) : (^) FirS Name
Laet Name. Level: (^) Select pay (^) Level
tAtege
Step 10: User hits the ' DELETE key^ and^ the^ selected^ employee^ has^ disappeared^ (from both the^ arraylist and, consequently,^ the^ listview).
,
'l I I 1 1