0% found this document useful (0 votes)
5 views5 pages

Practicals

The document contains multiple Java programming examples demonstrating various control flow statements including expressions, if statements, if-else statements, nested if statements, and do-while loops. Each example includes a simple program that outputs results based on the logic implemented. The output of each program is also indicated, showcasing the results of the evaluations and conditions checked.

Uploaded by

saniyakhade04560
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

Practicals

The document contains multiple Java programming examples demonstrating various control flow statements including expressions, if statements, if-else statements, nested if statements, and do-while loops. Each example includes a simple program that outputs results based on the logic implemented. The output of each program is also indicated, showcasing the results of the evaluations and conditions checked.

Uploaded by

saniyakhade04560
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Practical no:2

class Expression

public static void main(String args[])

int a=4;

int b=6;

int c=3;

int x=a+b/c;

int y=b-c*a;

System.out.println("evaluation result for x"+x);

System.out.println("evaluation result for y"+y);

Output:
Practical no:3
If statement:
public class Ifstatement

public static void main(String[] args) {

int age=20;

if(age>18){

System.out.print("Age is greater than 18");

Output:
If else statement:
public class LeapYearExample {

public static void main(String[] args) {

int year=2020;

if(((year % 4 ==0) && (year % 100 !=0)) || (year % 400==0)){

System.out.println("LEAP YEAR");

else{

System.out.println("COMMON YEAR");

Output:
Nested if statement:
public class JavaNestedIf {

public static void main(String[] args) {

int age=20;

int weight=80;

if(age>=18){

if(weight>50){

System.out.println("You are eligible to donate blood");

}}

Output:
Do while statement:
public class GFG {

public static void main(String[] args) {

int c = 1;

do {

System.out.println("Numbers: " + c);

c++;

} while (c <= 5);

Output:

You might also like