You are on page 1of 1

Southeast University

Department of Computer Science and Engineering


CSE2016: PROGRAMMING LANGUAGE – II
Lab 2
Questions:
1. Write a Java program that would take an input from the user and print that number.

2. The current in an alternating current circuit that contains resistance, capacitance,


and inductance in series is given by
E
I=
2
1
√ 2
(
R + 2 π fL−
2 π fC )
Where I=current (amperes), E=voltage (volts), R= resistance (ohms), L= inductance
(henrys), C= capacitance (farads) and f=frequency (hertz). Write a Java program that
reads values for the voltage, resistance, inductance, capacitance and frequency, and
then calculates and displays current.

3. Write a Java program that will ask the user to enter 5 numbers and will print the
users input after each entry. For example, if the user enters 2, the program will print
“You have entered 2”, then if the user enters 4 the program will print “You have
entered 4”, then if the user enters 23 the program will print “You have entered 23”.
This will go on till the user enters the 10 numbers.

4. Write a Java program that would take an input from the user and print “Even” if the
number is even and “Odd” if the number is odd.

5. Write a Java program that would input ten numbers from the user and print the ten
numbers in reverse order.

6. Write a java program that reads 5 numbers from the user, and then prints only the
even numbers (Assumption: user won’t input 0).

7. Write a java program that reads 5 numbers from the user, and then prints only the
odd numbers in reverse order (Assumption: user won’t input 0).

8. Write a Java program that will calculate the value of y if the expression of y is as
follows (n is the input):
y =12 −2 2 + 32 −4 2 + 52 ............ + n 2

You might also like