0% found this document useful (0 votes)
12 views3 pages

Test 1

The document contains six Java programming tasks, each requiring user input and performing specific calculations. Tasks include creating a simple calculator, summing odd and even numbers, calculating a series, finding HCF and LCM, checking for prime numbers, and printing a multiplication table. Each task is accompanied by sample input and expected output.

Uploaded by

baridharaghosh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

Test 1

The document contains six Java programming tasks, each requiring user input and performing specific calculations. Tasks include creating a simple calculator, summing odd and even numbers, calculating a series, finding HCF and LCM, checking for prime numbers, and printing a multiplication table. Each task is accompanied by sample input and expected output.

Uploaded by

baridharaghosh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Question 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:

Enter the first Number: 10


Enter the Second Number: 20
Choose operator from (+, -, *, /) : +
Sum of these numbers is 30

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:

Enter the first Number: 100


Enter the Second Number: 250
LCM = 500 , HCF = 50

Question 5:

Write a java program to check whether it is prime or not, the number should
be taken from the user.

Sample Input:

Enter the number : 17


17 is a prime number

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

You might also like