Java Programs Practice
Java Programs Practice
Java Programs Practice
Write a Java program to print 'Hello' on screen and your name on a separate line.
Expected Output :
Hello
Alexandra Abramov
Write a Java program to divide two numbers and print them on the screen.
Test Data :
50/3
Expected Output :
16
Write a Java program that takes two numbers as input and displays the product of two numbers.
Test Data:
Input first number: 25
Input second number: 5
Expected Output :
25 x 5 = 125
Write a Java program to print the sum (addition), multiply, subtract, divide and remainder of two numbers.
Test Data:
Input first number: 125
Input second number: 24
Expected Output :
125 + 24 = 149
125 - 24 = 101
125 x 24 = 3000
125 / 24 = 5
125 mod 24 = 5
Write a Java program that takes a number as input and prints its multiplication table up to 10.
Test Data:
Input a number: 8
Expected Output :
8x1=8
8 x 2 = 16
8 x 3 = 24
...
8 x 10 = 80
J a v v a
J aa v v aa
J J aaaaa V V aaaaa
JJ a a V a a
Write a Java program to compute the specified expressions and print the output.
Test Data:
((25.5 * 3.5 - 3.5 * 3.5) / (40.5 - 4.5))
Expected Output
2.138888888888889
Expected Output
Area is 5.6 * 8.5 = 47.60
Perimeter is 2 * (5.6 + 8.5) = 28.20
Write a Java program to print an American flag on the screen.
Expected Output
* * * * * * ==================================
* * * * * ==================================
* * * * * * ==================================
* * * * * ==================================
* * * * * * ==================================
* * * * * ==================================
* * * * * * ==================================
* * * * * ==================================
* * * * * * ==================================
==============================================
==============================================
==============================================
==============================================
==============================================
==============================================
Write a Java program to swap two variables.
+"""""+
[| o o |]
| ^ |
| '-' |
+-----+
Hexadecimal number is : F
Decimal Number: 4
HexaDecimal value: D
Octal number: 7