CS 260 Homework 5 Fall 2017

Verified

Added on  2019/09/16

|2
|587
|184
Homework Assignment
AI Summary
This is a homework assignment for CS 260, focusing on modifying a payroll program. The assignment requires students to use a SortedList for department data, implement input validation, and utilize parallel arrays for state tax rates. Students must also display output in an organized manner, including the correct department name based on the selected department number. The assignment emphasizes good design principles and the use of appropriate data types.
Document Page
CS 260 Homework 5 Fall 2017 Due: November 3, 2017
This is an individual assignment – design, code and debug your own project
As always, you may seek assistance from the instructor
1) Make corrections to Homework 4
Make sure you are getting the correct answers
Change code based on instructor feedback
2) Modify Homework 4 (Payroll) to add the following elements:
Edit the first and last names
o Change the first letter to capital and all other letters to lower case
Add a SortedList to your program – the Key will be a department number and the Value will be a
department name.
Add the following data to the SortedList (It’s easiest to initialize to these values when you declare
it)
14 Sales
18 Human Resources
23 Marketing
29 Research and Development
34 Customer Service
37 Finance
51 Production
52 Legal
66 Logistics
73 Purchasing
75 Information Technology
Add a ListBox or ComboBox to your form to hold the department number
Fill the ListBox or ComboBox with JUST the department numbers from the SortedList
o Using a loop, grab just the keys from the SortedList and add to the ListBox or ComboBox
o Do not hand type the department numbers into the properties window
Validate Input
o Use the validation functions from the textbook – IsPresent, IsDecimal, IsWithinRange, etc.
o Write one IsValidData function with Compound conditions in a single return statement (as
shown in book – bottom of page 225)
o Validations:
First Name Present
Last Name Present
Hours worked Present (not empty), Double, >=0, <=60
Pay rate Present, Decimal, >0, <= 99.99
YTD Gross Present, Decimal, >=0, <= 999,999.99
Allowances Present, Integer, >= 0, <= 20
Your organization has branches in several states. Each state has its own state tax rate. Create two
arrays (parallel arrays) – one for state names (string) and one for state tax rates (double) (see
below)
o Michigan 4.25%
o Indiana 3.23%
o Illinois 4.95% I would not use constants for tax rates, since you
o South Dakota 0.0% may have up to 50 in the future
o Colorado 4.63%
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
o Tennessee 6.0%
o Wyoming 0.0%
Search the first array for a matching state and find the corresponding tax rate in the second array
based on the index where the state was found.
Change you MichiganTax function to StateTax and pass the appropriate Tax Rate to the function to
calculate state tax.
Display output in an attractive manner:
Display the correct Department Name (not the number) that corresponds to the Department
Number chosen in the ListBox or ComboBox. Use SortedList properties and/or methods to
automate this process!
If the user does not select a department number, display “Unknown Department Code”.
Format dollar amounts as currency (DO NOT format input)
Line up numeric output at the decimal point (or right-most digit) and string data on the left-most
character, using PadLeft and/or PadRight if using a ListBox for your output.
Reminders:
Use good design elements as discussed in class
Use the correct data types – Decimal for money, Double for rates
Do your own work feel free to ask me for help
chevron_up_icon
1 out of 2
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]