Computer Applications
Practical Assignment
1) Write a program in Java to compute the perimeter and area of a triangle, with its three sides given as a = 11, b = 12, and c = 13 using the following formulas:
2) Write a program in Java to find the area, perimeter, and diagonal of a square and display the output of the program. (Given: side of a square = 25)
3) Write a program in Java to input the name and basic salary of an employee. Calculate and display the gross salary and net salary when:
da= 30% of basic
hra= 12.5% of basic
pf= 10% of basic
gross = basic + da + hra
net pay = gross – pf
4) Write a program in Java to input two numbers. Display the numbers after swapping them by using a third variable.
Sample Input: a= 95, b=45
Sample Output: a=45, b-95
5) Write a program in Java that takes input using the Scanner class to calculate the Simple Interest with the given values:
i. Principle Amount = Rs.1,00,000
ii. Rate = 11.5%
iii. Time = 5 years
6) Write a program to input a number. Using math class functions calculate its square root and cube root. Finally, display the result by rounding it off.
Sample Input: 5
Square root of 5= 2.2360679 Rounded form= 2
Cube root of 5 = 1.7099759 Rounded form= 2
7) Write a program that inputs a number and tests if the given number is a multiple of 3 and 5.
8) In an examination, the grades are awarded to the students in 'Science" according to the average marks obtained in the examination.
Marks Grades
80% and above Distinction
60% or more but less than 80% First Division
45% or more but less than 60% Second Division
40% or more but less than 45% Pass
Less than 40% Promotion not granted
Write a to input name and marks in Physics, Chemistry and Biology. Calculate the average marks. Display the name, average marks, and the grade obtained.
Sample output: VIBGYOR Spectrum
Enter your color choice : Y
Yellow
10) Using the switch statement, write a menu-driven program:
i) To check and display whether a number input by the user is a composite number or not.
A number is said to be composite if it has one or more than one factor excluding 1 and the number itself.
Example: 4, 6, 8, 9...
ii) To find the smallest digit of an integer that is input:
Sample input: 6524
Sample output: Smallest digit is 2