Note: Archive every assignment problem's class & java files individually (i.e. assigment1.zip contain UofKPayrol.class and UofKPayrol.java)
Submit to : sdlabuofk@gmail.com with your name and index as email's subject.
Deadline 26/11/2016 23:59:59
Assignment
1: [4 Marks]
University of Khartoum needs a program to calculate how
much to pay their hourly employees. The Sudanese Department of Labor requires
that employees get paid time and a half for any hours over 40 that they work in
a single week. For example, if an employee works 45 hours, they get 5 hours of
overtime, at 1.5 times their base pay. The Khartoum Locality requires that
hourly employees be paid at least 8.00
SDG an hour. The University Human resources requires that an employee
not work more than 60 hours in a week.
These rules can be summarized in:
- An employee gets paid (hours worked) × (base pay), for each hour up to 40 hours.
- For every hour over 40, they get overtime = (base pay) × 1.5.
- The base pay must not be less than the minimum wage (8.00 SDG an hour). If it is, print an error. If the number of hours is greater than 60, print an error message.
Create a new class called UofKPayrol
Write a method that takes the base pay and hours worked as parameters, and prints the total pay or an error. Write a main method that calls this method for each of these employees:
These rules can be summarized in:
- An employee gets paid (hours worked) × (base pay), for each hour up to 40 hours.
- For every hour over 40, they get overtime = (base pay) × 1.5.
- The base pay must not be less than the minimum wage (8.00 SDG an hour). If it is, print an error. If the number of hours is greater than 60, print an error message.
Create a new class called UofKPayrol
Write a method that takes the base pay and hours worked as parameters, and prints the total pay or an error. Write a main method that calls this method for each of these employees:
Base Pay Hours Worked
Employee
1 SDG 7.50 35
Employee
2 SDG 8.20 47
Employee 3 SDG 10.00 73
Assignment 2: [4 Marks]
A group of UofK friends decide to run a Marathon . Their names and times (in minutes) are below:
A group of UofK friends decide to run a Marathon . Their names and times (in minutes) are below:
Name Time (minutes)
Ahmed 341
Ali 273
Lena 278
Suzie 329
Shadi 445
Omar 402
Yassin 388
Essra 275
John 243
Tariq 334
Yahia 412
Lelian 393
Alaa 299
Noor 343
Yassir 317
Katy 265
Write a method that takes as input an array of integers and returns the index corresponding to the person with the lowest time. Run this method on the array of times. Print out the name and time corresponding to the returned index.
Write a second method to find the
second-best runner. The second method should use the first method to determine
the best runner, and then loop through all values to find the second-best
(second lowest) time.
Here is a program skeleton to get
started:
class UOFKMarathon { public static
void main (String[] arguments) {
String[] names = {
“……”,””
};
int[]
times = {
341, 273, …………….
}; for (int i = 0;
i < names.length; i++) {
…………………………………… System.out.println(names[i] + ": " + times[i]);
…………………………………… System.out.println(names[i] + ": " + times[i]);
}
}
}
Assignment
3: [4 Marks]
Define a class Complex that can
be used to represent complex numbers. The class should provide support to the
following operations:
a.
Addition, subtraction, multiplication, and division of two complex numbers.
b.
Absolute value and angle (argument) of the complex number.
c. String representation of the
complex number in the form r + im (r= real part, m = imaginary part).
Usage
example:
Complex num1 = new Complex(3, 4); // 3 + 4i
Complex num2 = new Complex(1, -2); // 1 -2i
Complex sum = Complex.add(num1, num2);
double absVal = sum.abs();
System.out.println(sum);
// Displays 4 + 2i
Assignment 4: [4 Marks]
5.1. Write a
program that takes a file name and a word from the user. It then searches the
file for the occurrences of the word and then prints the number of times the
word has appeared in the file. [2 Marks]
5.2. Add to
the previous program the ability to replace each instance of the word with
another word given by the user. [2 Marks]
Bonus:
Write a
menu-driven program that manages employee’s records. The program should provide
two basic functionalities:
1. Display current employee’s data.
2. Add a new employee record and store it on disk.
Usage
example (Text in green represents user input):
Employees
management software. Press 1 to display current employees, 2 to add a new
employee, or 3 to exit: 1
Current
employees:
Name Salary Age
Abbas 1200 22
Ali 2200 21
Employees
management software. Press 1 to display current employees, 2 to add a new
employee, or 3 to exit: 2
Adding a new
employee
Name: Amina
Salary: 2300
Age: 24
Employee
Amina has been added.
Employees
management software. Press 1 to display current employees, 2 to add a new
employee, or 3 to exit: 3
Bye.
No comments:
Post a Comment