Test 1
Test 1
Write a Java program to create a simple calculator. You should ask for two
numbers from the user and an operator (+, -, *, /). Use a switch case to perform
the corresponding operation and display the result.
Sample Input:
Question 2:
Write a Java program to calculate the sum of all odd numbers and even
numbers separately between 1 and a number entered by the user. Use a while loop
to perform the calculation and if-else to check whether a number is odd or even.
Display both sums at the end.
Sample Input:
Enter a number : 10
Sum of all Odd numbers is 25
Sum of all even number is 30
Question 3:
Write a java program to calculate the value of the underwritten series up to Nth
term , Value of N should be taken from the user.
1 1 1 1
Series :
2
+4 + 8
+ 16
+ … up to N terms
Sample Input:
Enter value of N : 3
Sum up to 3 terms is 0.875000
Question 4:
Write a java program to calculate the value of HCF ( Highest Common Factor
) and LCM ( Least Common Multiplier ) of 2 numbers. Value of the numbers should
be taken from the user.
Sample Input:
Question 5:
Write a java program to check whether it is prime or not, the number should
be taken from the user.
Sample Input:
Question 6:
Write a java program to print table of a number taken from the user.
Sample Input:
Enter a number : 5
5*1=5
5 * 2 = 10
5 * 3 = 15
5 * 4 = 20
5 * 5 = 25
5 * 6 = 30
5 * 7 = 35
5 * 8 = 40
5 * 9 = 45
5 * 10 = 50