Practice Worksheet Basic of Java
Practice Worksheet Basic of Java
class Sum {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println("Sum: " + (a + b));
}
}
class EvenOdd {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
if (num % 2 == 0)
System.out.println("Even");
else
System.out.println("Odd");
}
}
4. Area of a circle
java
CopyEdit
import java.util.Scanner;
class CircleArea {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double r = sc.nextDouble();
double area = 3.14 * r * r;
System.out.println("Area = " + area);
}
}
class Result {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int marks = sc.nextInt();
if (marks >= 40)
System.out.println("Pass");
else
System.out.println("Fail");
}
}
No Copyright Claimed
This material has been created for educational purposes and is intended for
free public use.
The content in this document is released into the public domain by the author
and contributors.
You are free to copy, share, modify, distribute, or use this material in any form,
with or without attribution.
This resource was created with the support of AI tools and compiled by Annexa
Academics for the benefit of students and educators.
****************************************************************