Assignment 3
Assignment 3
1. Company has decided to train their employees as 3 groups, they require new desks
for that. only 2 employees may share one desk. now the task is to count the number of
desks to order from the shop. Company try to reduce the expenditure so calculate the
minimum number of desks. But don't forget that each group will sit in one room. The
program should read the number of employees in each of the three groups.
Example:
group1: 20
group2: 21
group3: 22
Output
Required desks:32
2. Write a java program to read a number with an even number of digits. If the sum of
the first half of the digits equals the sum of the second half of the digits, then this
number is considered lucky. Print"YES" if this number is lucky, otherwise print
"NO".
Arrays
3. Create three arrays to store data about five people. The first array should be Strings
and should hold their last names. The next array should be doubles and should hold
a grade average (on a 100-point scale). The last array should be ints, should hold
their student id numbers.
Give each of the arrays values (using array initializers). Then print the values of all
three arrays on the screen.
Finally, ask the user for an ID number to lookup. Search through the ID array until
you find that ID, and then print out the values from the same slot number of the
other two arrays.
7. Patient / Doctor Scheduler – Create a patient class and a doctor class. Have a doctor
that can handle multiple patients and setup a scheduling program where a doctor
can only handle 16 patients during an 8 hr work day.
8. In a group of 50 people 15 like drinking tea, 17 like drinking coffee, remaining
people like milk.
Exception Handling
11. Write a java program to read two strings by taking user input , and perform division
operation by converting the strings into integers. If Num1 or Num2 were not an
integer, the program would throw a NumberFormatException. If Num2 were Zero,
the program would throw an Arithmetic Exception
12. Write a java program to raise user defined exception and catch the exception if the
two vehicle are in opposite direction
13. Write a java program to read name and age of an employee(User input) if age is
greater than 100 then it should throw ageException, if name contains digits it
should throw nameException?