0% found this document useful (0 votes)
2 views

Assignment 3

The document outlines a series of programming tasks in Java, including employee desk allocation, lucky number identification, array manipulation, string operations, class and object creation, and exception handling. Each task specifies input requirements, expected outputs, and additional functionalities such as inheritance and user-defined exceptions. The tasks aim to enhance programming skills through practical applications in various scenarios.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Assignment 3

The document outlines a series of programming tasks in Java, including employee desk allocation, lucky number identification, array manipulation, string operations, class and object creation, and exception handling. Each task specifies input requirements, expected outputs, and additional functionalities such as inheritance and user-defined exceptions. The tasks aim to enhance programming skills through practical applications in various scenarios.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Basic Programs

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:

Input(3 integer Values)

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.

4. Write a program to accept 10 students marks in an array, arrange it in ascending


order, convert into the following grades and print marks and grades. Between 40
and 50 PASS between 51 and 75 MERIT and above DISTINCTION
Strings

5. Write a Java program to remove white spaces in a sentence.


6. Write a program to check if two given String is Anagram of each other. Your
program should return true if two Strings are Anagram, false otherwise. A string is
said to be an anagram if it contains the same characters and same length, but in a
different order, e.g. army and Mary are anagrams.

Class and objects

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.

TeaPrice-7Rs, CoffeePrice-10Rs, MilkPrice-6 Rs.(Each glass).Now calculate total bill


they have to be paid?

Implements inheritance where café (TeaPrice, CoffePrice, MilkPrice as final)is Base


class. Consider Tea(No. of tea glasses), Coffee(No. of coffee glasses), Milk(No. of milk
glasses) as derived classes.

 Define parameterized constructors in each derived class.


 Define method in each derived class to display individual
bills(TeaBill(),CoffeeBill(),MilkBill())
 Call methods in main class to display total bill
9. Create an abstract class CollegeData with the information of member i.e. name,
address, contact, date_of_join, through methods getName (),getAddress (),
getContact (), getDate_of_Join () and derive sub-classes Employee and Student with
method Qualification () to print the related information with his/her qualification.

10. Create an interface House with the information of


i.e,numberofrooms(),numberofwindows(),numberoffloor() .And derive subclasses
single,double bedroom with method getRent() .

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?

You might also like