Instructions
Use InputStreamReader and BufferedReader class to get input from the users.
Try to get input from the key board for all the programs.
Try to get execute program in your own laptop add screen shot as output.
Try to use your own logic (don’t copied from others, Internet or any other
resources).
Try to upload all programs in a single file as PDF file format.
Questions:
1. Write a Java program to get a number from the user and print whether it is positive or
negative.
2. Write a Java program to solve quadratic equations (use if, else if and else).
3. Take three numbers from the user and print the greatest number.
4. Write a Java program that reads a floating-point number and prints "zero" if the
number is zero. Otherwise, print "positive" or "negative".
5. Write a Java program that keeps a number from the user and generates an integer
between 1 and 7 and displays the name of the weekday.
6. Write a Java program that takes a year from user and print whether that year is a leap
year or not.
7. Write a program in Java to display the first 10 natural numbers.
8. Write a program in Java to display n terms of natural numbers and their sum.
9. Write a program in Java to input 5 numbers from keyboard and find their sum and
average.
10. Write a program in Java to display the square of the number upto given an integer.
11. Write a program in Java to display the cube of the number upto given an integer.
12. Write a program in Java to display the multiplication table of a given integer.
13. Write a program in Java to display the n terms of odd natural number and their sum.
14. Write a program in Java to display the pattern like right angle triangle with a number.
Test Data
Input number of rows : 10
Expected Output :
1
12
123
1234
12345
123456
1234567
12345678
123456789
12345678910
15. Write a Java program that reads an positive integer and count the number of digits the
number
Test Data
Input an integer number : 125463
Expected Output :
Number of digits in the number: 6
16. Write a Java program to add two binary numbers.
Input Data:
Input first binary number: 10
Input second binary number: 11
Expected Output
Sum of two binary numbers: 101
17. Write a java program to define string array and display those values.
18. Java program to perform addition, subtraction and multiplication of given two matric.
19. Write a Java program to check whether given number is prime or not.
20. Write a Java program to print prime number from 2 to N.
Test Data:
N value: 20
Output Data:
2 3 5 7 11 13 17 19
21. Write a Java program to compute value of following series
1-3+5-7+…+N
22. Write a simple Java program which will print Fibonacci series, e.g. 1 1 2 3 5 8
13 ... . up to a given number.
23. Write a program to check if the given number is Armstrong number or not.
For example, 153 is an Armstrong number because of 153= 1+ 125+27, which is
equal to 1^3+5^3+3^3
24. Write a program to remove duplicates from an array in Java (without using any built
in function)
Example:
Input:
Array1 = {1,4,5,4,6,6,10}
Output:
Original Array = {1,4,5,4,6,6,10}
Expected Array = {1,4,5,6,10}
25. Write a Java program to compute the value of exponential series:
Sum = 1 + x/1! + x^2/2! + x^3/3! + ......
26. Write a Java program to compute the value of following series:
Sum = x^2/2! - x^4/4! + x^6/6! - x^8/8!......
27. Write a Java program to compute the value of following series:
Sum = x - x^3/3! + x^5/5! - x^7/7!......
28. Write a Java program to create a method to compute the addition, subtraction,
multiplication and division of given two numbers.
29. Write a Java program to find factorial of a given number using recursive method.
30. Write a Java program to compute the value of m^n using method.