Java Vezbi
Java Vezbi
Write a Java program to print 'Hello' on screen and then print your name on a
separate line. Go to the editor
Expected Output :
Hello
Alexandra Abramov
2. Write a Java program to print the sum of two numbers. Go to the editor
Test Data:
74 + 36
Expected Output :
110
import java.util.Scanner;
3. Write a Java program to divide two numbers and print on the screen. Go to the
editor
Test Data :
50/3
Expected Output :
16
import java.util.Scanner;
4. Write a Java program to print the result of the following operations. Go to the
editor
Test Data:
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
import java.util.Scanner;
if (i==0)
if (i==1)
if (i== 3)
if (i==2)
else;
5. Write a Java program that takes two numbers as input and display the product
of two numbers. Go to the editor
Test Data:
Input first number: 25
Input second number: 5
Expected Output :
25 x 5 = 125
import java.util.Scanner;
6. Write a Java program to print the sum (addition), multiply, subtract, divide and
remainder of two numbers. Go to the editor
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
import java.util.Scanner;
if(i==0)
if(i==1)
if(i==2)
if(i==3)
if(i==4)
System.out.println(" J a v v a ");
System.out.println(" J a a v v a a ");
System.out.println(" J J aaaaa v v aaaaa");
System.out.println(" JJ a a v a a");
9. Write a Java program to compute the specified expressions and print the
output. Go to the editor
Test Data:
((25.5 * 3.5 - 3.5 * 3.5) / (40.5 - 4.5))
Expected Output
2.138888888888889
public class Main {
11. Write a Java program to print the area and perimeter of a circle. Go to the
editor
Test Data:
Radius = 7.5
Expected Output
Perimeter is = 47.12388980384689
Area is = 176.71458676442586
import java.util.Scanner;
12. Write a Java program that takes three numbers as input to calculate and print
the average of the numbers. Go to the editor
import java.util.Scanner;
}
}
13. Write a Java program to print the area and perimeter of a rectangle. Go to the
editor
Test Data:
Width = 5.5 Height = 8.5
Expected Output
Area is 5.6 * 8.5 = 47.60
Perimeter is 2 * (5.6 + 8.5) = 28.20
import java.util.Scanner;
14. Write a Java program to print an American flag on the screen. Go to the
editor
Expected Output
* * * * * * ==================================
* * * * * ==================================
* * * * * * ==================================
* * * * * ==================================
* * * * * * ==================================
* * * * * ==================================
* * * * * * ==================================
* * * * * ==================================
* * * * * * ==================================
==============================================
==============================================
==============================================
==============================================
==============================================
==============================================
int temp=first;
first=second;
second=temp;
System.out.println("+\"\"\"\"\"+");
System.out.println("[| o o |]");
System.out.println(" | ^ | ");
17. Write a Java program to add two binary numbers. Go to the editor
Input Data:
Input first binary number: 10
Input second binary number: 11
import java.util.Scanner;
int prenos=0,i=0;
binary1 = binaryn.nextLong();
binary2 = binaryn.nextLong();
if (prenos != 0) {
sum[i++] = prenos;
--i;
while (i >= 0) {
System.out.print(sum[i--]);
System.out.print("\n");