Core Java Exercises Section1:Basics
Core Java Exercises Section1:Basics
==========================================================
Section1 :Basics
==========================================================
1. Write a Java program to print the result of the following operations.
a. -5 + 8 * 6
b. (55+9) % 9
c. 20 + -3*5 / 8
d. 5 + 15 / 3 * 2 - 8 % 3
Expected Output:
43
1
19
13
a) 101 + 0) / 3
b) 3.0e-6 * 10000000.1
c) true && true
d) false && true
e) (false && false) || (true && true)
f) (false || false) && (true && true)
Expected Output:
(101 + 0) / 3)-> 33
(3.0e-6 * 10000000.1)-> 30.0000003
(true && true)-> true
(false && true)-> false
((false && false) || (true && true))-> true
(false || false) && (true && true)-> false
Specified Formula :
4.0 * (1 - (1.0/3) + (1.0/5) - (1.0/7) + (1.0/9) - (1.0/11))
Expected Output
2.9760461760461765
Test Data
Input weight in pounds: 452
Input height in inches: 72
Expected Output
6. Write a Java program to solve quadratic equations (use if, else if and else)
Test Data
Input a: 1
Input b: 5
Input c: 1
Expected Output:
The roots are -0.20871215252208009 and -4.7912878474779195
7.Write a Java program that accepts two floating point numbers and checks whether they are the
same up to two decimal places.
Test Data
Input first floating point number:2.585
Input second floating point number: 2589
Expected Output:
10.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.