Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

1.

Write a java program to accept three integers from command line arguments and display average of
3.

2. Write a java program to accept hieght and breadth from user and display area of right angle triangle.

3. Write a java program to accept radius from user and display area of circle.

4. Write a program to accept total number of seconds from user, and convert in HH:MM:SS format.

ex: 3800 should display 1:3:20

5. Write a program to accept three integers and display larget of three.

6. Implement assignment 5 using conditional operator.

7. Create a calculator in java. Accept two numbers and a choice from user as command line arguments,
if choice is

1 display addition

2 display substraction

3 display multiplication

4 display division

otherwise display invalid choice

8. Implement assignment 7 using switch statement. Also use Scanner class to read all inputs.

9. Write a program to accept a number from user and display table of that number.

10. Write a program to accept a number from user and display fibonacci series upto that number.

1 1 2 3 5 8 13 21 34.......
11. Write a program to accept a number from user and check whether it prime or not.

12. Create an application for a mobile company. This application should accept total number of calls
made and customer plan. The application should display the total bill for the customer. Plan details are
as follows :

planA

1.1 Monthly Rental is 100

1.2 First 100 calls are free.

1.3 Call charges for calls made between 100-200 is 0.75

1.4 Call charges for calls made between 200-300 is 1.0

1.5 Call charges for calls made above 300 is 1.25

230 100+0+75+30 = 205

planB

1.1 Monthly Rental is 150

1.2 First 100 calls are free.

1.3 Call charges for calls made between 100-200 is 0.50

1.4 Call charges for calls made between 200-300 is 0.75

1.5 Call charges for calls made above 300 is 1.00

planA

1.1 Monthly Rental is 200

1.2 First 100 calls are free.

1.3 Call charges for calls made between 100-200 is 0.25

1.4 Call charges for calls made between 200-300 is 0.50

1.5 Call charges for calls made above 300 is 0.75


case "A" :

double total = 0;

if(calls<100)

total = 100;

else

if(calls >100 && calls <200)

total = 100 + (calls-100)*0.75;

else

if(calls >200 && calls <300)

total = 100 + 75 + (calls-200)*1;

else

total = 100 + 75 + 100 + (calls-300)*1.25;

13. Accept Month from user(No 1-12 for Jan-Dec) & display the season associated with the month.

14 Create Java application (java prog) to display the cmd line argument in reverse manner.

15. Write a java program to create an array of 5 integers and display the median.(size should be odd)
16. Write a java program which accepts 5 integers and display largest and smallest number in from the
array.

17. Write a java program which accepts a number from user and search this number in an
array.(Initialize an array with 10 values).

18. Write a java program which accepts 5 names and display the largest name.

19. Write a java program to search a name in an array.

20. Write a java program which accepts the size of an integer array ,create an array of that size and
accept integers from user. Create Two more arrays called evenNumbers and oddNumbers, save all even
numbers from main array into evenNumbers and save all odd numbers from main array into
oddNumbers.

21. Open javadoc (google) and read about String class.

22. Create a class called Arithmetic, which must provide all arithmethic functionalities.

23. Creat a class call AreaCalculator which contains methods to calculate area of circle, area of square
and area of triangle.

24. Create a class rectangle in package "geom" . The class has private attributes length and width, each
of which defaults to 1. It should have member methods that calculate the perimeter and area of the
rectangle. It should have set and get functions for both length and width. The set functions should verify
that length and width are each floating-point numbers larger than 0.0 and less than 20.0.

Write TestRect class in package "test_geom" : to create 2 rectangles & invoke setters/geters & display
perimeter & area.

25. Create Java Application for the following .

Create Point class Point2D : for representing a point in x-y co-ordinate system.
Create a parameterized constructor to accept x & y co-ords.

Must use toString method : to return the x & y coords

Add isEqual method : boolean returning method : must ret. true if both points are having same x,y co-
ords or false otherwise. : (public boolean isEqual(Point2D p))

Create Point2D class in geom package.

Write TestPointArray class. Accept no of points to be made from the user : use scanner

Accept the point x,y co-ords from the user using Scanner class.

& display the dimensions from the single for-each loop.

Create this class in test package.

26. Create Java Application for the following .

Create Point class Point2D : for representing a point in x-y co-ordinate system.

Create a parameterized constructor to accept x & y co-ords.

Add show method : to return the x & y coords .(public String show())

Add isEqual method : boolean returning method : must ret. true if both points are having same x,y co-
ords or false otherwise. : (public boolean isEqual(Point2D p))

Create Point2D class in geom package.

Write TestPoint class having main method. Create two points passing passing arguments to
parameterized constructor. Accept x and y co-ods from user using Scanner class. Invoke show method
and isEqual method.

Create this class in tester package.


27. Create a class called AreaCalculator which calculates area of different shapes using static overloaded
methods.(different shapes are square, rectangle, triangle and circle).

28.

1.Create Java Application for the Payroll system .

The employee categories in the organization are :

1.1

SalariedEmployee - id,name,addr,deptId,basic,hra,da

Net sal=basic + hra + 20 % of da

1.2

CommissionEmp - id,name,addr,deptId,grossSales,commissionRate

Net Sal = grossSales*commissionRate

1.3

PartWorker - id,name,addr,deptId,partsMade,ratePerPart

Net Sal=basic+(partsMade*ratePerPart)

Create Tester Java Application for the following.

Ask user --- for no of emps in organization.

Display Menu

1. Enter 1.1 Details

2. Enter 1.2 Details

3. Enter 1.3 Details

4. Display Emp dtls & net sal

5 . Display the employee Name whose earning( net salary) is maximum in the organization.

6. Exit

Add these emps in a suitable array.

Thus organization currently has : 3 types of emps.

Using single for-each loop disp Emp details(must use toString)

Along with emp dlts , disp the following


If the Emp is 1.1 : display HRA

If the Emp is 1.2 : disp commissionRate

If the Emp is 1.3 : disp parts made.

1. Create Java application for fixed stack & growable stack of integer.(Hint : Stack interface & imple. class
FixedSt & GrowableSt) From tester class --- display Menu

1 -- Push data

2 ---Pop data

3 -- Exit

You might also like