Advance Java Programming Practice Problems

Problem : 1
AdvanceBasic

Factorial of any number n is represented by n! and is equal to 1*2*3*....*(n-1)*n. E.g.- 4! = 1*2*3*4 = 24 3! = 3*2*1 = 6 2! = 2*1 = 2 Also, 1! = 1 0! = 0 Write a Java program to calculate factorial of a number.

Problem : 2
AdvanceBasic

Consider an integer array, the number of elements in which is determined by the user. The elements are also taken as input from the user. Write a program to find those pair of elements that has the maximum and minimum difference among all element pairs.

Problem : 3
AdvanceBasic

Write a program to find greatest common divisor (GCD) or highest common factor (HCF) of given two numbers

Problem : 4
AdvanceBasic

A three digit number is called Armstrong number if sum of cube of its digit is equal to number itself. E.g.- 153 is an Armstrong number because (13)+(53)+(33) = 153. Write all Armstrong numbers between 100 to 500.

Problem : 5
AdvanceBasic

A person is elligible to vote if his/her age is greater than or equal to 18. Define a method to find out if he/she is elligible to vote. Write a Java program

Problem : 6
AdvanceBasic

Write a program to print the factorial of a number by defining a method named 'Factorial'. Factorial of any number n is represented by n! and is equal to 1*2*3*....*(n-1)*n. E.g.- 4! = 1*2*3*4 = 24 3! = 3*2*1 = 6 2! = 2*1 = 2 Also, 1! = 1 0! = 0

Problem : 7
AdvanceBasic

Define a method named 'perfect' that determines if parameter number is a perfect number. Use this function in a program that determines and prints all the perfect numbers between 1 and 1000. [An integer number is said to be "perfect number" if its factors, including 1(but not the number itself), sum to the number. E.g., 6 is a perfect number because 6=1+2+3].

Problem : 8
AdvanceBasic

Define a method to calculate power of a number raised to other i.e. ab using recursion where the numbers 'a' and 'b' are to be entered by the user

Problem : 9
AdvanceBasic

Write a program that takes as input your gross salary and your total saving and uses another function named taxCalculator() to calculate your tax. The taxCalculator() function takes as parameters the gross salary as well as the total savings amount. The tax is calculated as follows: (a) The savings is deducted from the gross income to calculate the taxable income. Maximum deduction of savings can be Rs. 100,000, even though the amount can be more than this. (b) For up to 100,000 as taxable income the tax is 0 (Slab 0); beyond 100,000 to 200,000 tax is 10% of the difference above 100,000 (Slab 1); beyond 200,000 up to 500,000 the net tax is the tax calculated from Slab 0 and Slab 1 and then 20% of the taxable income exceeding 200,000 (Slab 2); if its more than 500,000, then the tax is tax from Slab 0, Slab 1, Slab 2 and 30% of the amount exceeding 500,000.

Problem : 10
AdvanceBasic

Take 20 integer inputs from user and print the following: number of positive numbers number of negative numbers number of odd numbers number of even numbers number of 0s.

For More Programming Practice Questions