I am sharing 'DOC-20250109-WA0013.' with you
I am sharing 'DOC-20250109-WA0013.' with you
I am sharing 'DOC-20250109-WA0013.' with you
System.out.println("Hello, World!");
Output:
Hello, World!
import java.util.Scanner;
}
}
Output:
Sum: 30
import java.util.Scanner;
Output:
Enter radius: 5
Area: 78.53981633974483
System.out.println("Simple Calculator");
System.out.println("1. Addition");
System.out.println("2. Subtraction");
System.out.println("3. Multiplication");
System.out.println("4. Division");
double result = 0;
switch (choice) {
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
default:
System.out.println("Invalid choice");
return;
Output:
Simple Calculator
1. Addition
2. Subtraction
3. Multiplication
4. Division
Enter choice: 1
Result: 30.0
Question: Write a Java program to calculate the total marks and average marks of a student.
import java.util.Scanner;
Output:
Math: 80
Science: 70
English: 90
Total: 240
Average: 80.0
import java.util.Scanner;
Output:
import java.util.Scanner;
int factorial = 1;
factorial *= i;
Output:
Enter a number: 5
Factorial: 120
import java.util.Scanner;
if (num % i == 0) {
isPrime = false;
break;
if (isPrime) {
} else {
Output:
Enter a number: 23
23 is a prime number.
import java.util.Scanner;
int n = sc.nextInt();
int t1 = 0, t2 = 1;
t1 = t2;
t2 = sum;
Output:
Fibonacci Series: 0 1 1 2 3 5 8 13 21 34
import java.util.Scanner;
int reverse = 0;
while (num != 0) {
num /= 10;
}
if (original == reverse) {
} else {
Output:
121 is a palindrome.
import java.util.Scanner;
int[] array = {2, 5, 8, 12, 16, 23, 38, 56, 72, 91};
if (result == -1) {
} else {
}
public static int binarySearch(int[] array, int target) {
int left = 0;
if (array[mid] == target) {
return mid;
left = mid + 1;
} else {
right = mid - 1;
return -1;
Output:
import java.util.Scanner;
System.out.println("Original array:");
printArray(array);
bubbleSort(array);
System.out.println("Sorted array:");
printArray(array);
int n = array.length;
array[j + 1] = temp;
System.out.println();
}
Output:
Original array:
64 34 25 12 22 11 90
Sorted array:
11 12 22 25 34 64 90
Question: Write a Java program to calculate the area and perimeter of a rectangle.
import java.util.Scanner;
Output:
Enter the length of the rectangle: 10
import java.util.Scanner;
int sum = 0;
if (num % i == 0) {
sum += i;
if (sum == num) {
} else {
}
Output:
Enter a number: 6
6 is a perfect number.
import java.util.Scanner;
int n = sc.nextInt();
int t1 = 0, t2 = 1;
t1 = t2;
t2 = sum;
}
Output:
Fibonacci Series: 0 1 1 2 3 5 8 13 21 34
import java.util.Scanner;
reverse += str.charAt(i);
if (str.equals(reverse)) {
} else {
}
Output:
madam is a palindrome.
import java.util.Scanner;
int gcd = 1;
gcd = i;
System.out.println("GCD of " + num1 + " and " + num2 + " is " + gcd);
}
Output:
GCD of 48 and 18 is 6