Practical Assignment
14)
A Pre-Paid
taxi charge from the passenger as per the tariff given below:
Write a program to input the distance covered and calculate the amount paid by the passenger. The program displays the printed bill with the details given below:
Taxi No. :
Distance covered
:
Amount :
15) Using a switch
case statement, write a menu-driven program to calculate the area of the following geometric shapes.
i) area
of circle ( area of circle = π*r2)
ii)
area of rectangle (area of rectangle = l*b)
iii) area
of square (area of Square = side * side)
16)
Write a Java
program to print the Fibonacci series up to n terms where n is user input.
17)
Write a Java
program to calculate the sum of digits of a number entered by the user.
18)
Write a Java
program to check and display whether the entered number is an Armstrong number or
not.
19)
Write a Java
program to check and display whether the entered number is a Prime number or not.
20)
Write a Java
program to check and display whether the entered number is a Special number or
not.
(A number is said to be a special number if the sum
of the factorial of the digits of the number is the same as the original number.)
For example 145 is special number, because 1! + 4! +
5! = 1 + 24 + 120 = 145
21)
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.
(ii) To find the smallest digit of an integer that
is input.
For
an incorrect choice, an appropriate message should be displayed.
22)
Write a Java
program to print the sum of series 1 + (1+2) + (1+2+3)…….(1+2+3+…+n). The program
should ask for the value of a number of terms n.
23) Write a Java program to print the following pattern.
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
24) Write a Java program to print the following pattern.
1 2 3 4 5
2 3 4 5
3 4 5
4 5
5
25) Write a Java program to print the following pattern.
A
A B
A B C
A B C D
A B C D E