proj comp (1) (1)
proj comp (1) (1)
Write a program to extract a portion of a character string and print the extracted string. Assume
that m characters are extracted, starting with the nth character.
Sample Input:
= ₹(12000 - 1200)
= ₹(10800 - 864)
Up to ₹25,000 5.0%
name
price
dis
amt
Member Methods:
Write a main method to create an object of the class and call the member methods.
Variable name Data type Description
name String To input the name
of the purchaser
price;p int To input/store the price of
the purchased item
respectively.
dis double To calculate the discount
amt double To calculate the total bill
amount
USER-DEFINED FUNCTIONS
Write a program using method name Glcm(int,int) to find the Lowest Common Multiple (LCM) of
two numbers by GCD (Greatest Common Divisor) of the numbers. GCD of two integers is
calculated by continued division method. Divide the larger number by the smaller, the remainder
then divides the previous divisor. The process is repeated till the remainder is zero. The divisor
then results in the GCD.
Formula:
(where a and b are the parallel sides, h is the perpendicular distance between the parallel sides)
Variable name Data type Description
Base double Input the base of the
parallelogram
ht double Input the height of the
parallelogram
d1 double Input the first diagonal of the
rhombus
d2 double Input the second diagonal of the
rhombus
a double First side of the trapezium
b double Second side of the trapezium
h double Input the height of the trapezium
ARRAY PROGRAMS
Write a program to accept the year of graduation from school as an integer value from the user.
Using the binary search technique on the sorted array of integers given below, output the
message "Record exists" if the value input is located in the array. If not, output the message
"Record does not exist".
Pattern 1
I
C
S
E
Pattern 2
I
C
S
E
Variable name Data type Description
ch Int Choice input by the user
str String Word input by the user
len int Store the length of the word
i int Loop variable
j int Loop variable
Write a program to input a number and check and print whether it is a Pronic number or not.
(Pronic number is a number which is the product of two consecutive integers.)
Example: 12 = 3 x 4
20 = 4 x 5
42 = 6 x 7
Write a program in Java that inputs the number of hours worked and the total sales. Compute
the wages of the employees.