0% found this document useful (0 votes)
4 views

Java Experiment No 1

Java

Uploaded by

rcymcdg4xx
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Java Experiment No 1

Java

Uploaded by

rcymcdg4xx
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 3

Java experiment no 1:

Q.1

public class Main

public static void main(String[] args) {

System.out.println("Hello World");

Output:

Hello World

Q.2

public class Main

public static void main(String[] args) {

int b =20;

int a =80;

int sum=a+b;

System.out.println(sum);

Output :-

100
Q.3

import java.util.Scanner;

public class Exercise3 {

public static void main(String[] args) {

Scanner in = new Scanner(System.in);

System.out.print("Input the 1st number: ");

int num1 = in.nextInt();

System.out.print("Input the 2nd number: ");

int num2 = in.nextInt();

System.out.print("Input the 3rd number: ");

int num3 = in.nextInt();

if (num1 > num2)

if (num1 > num3)

System.out.println("The greatest: " + num1);


if (num2 > num1)

if (num2 > num3)

System.out.println("The greatest: " + num2);

if (num3 > num1)

if (num3 > num2)

System.out.println("The greatest: " + num3);

Output:

Input the 1st number: 25

Input the 2nd number: 78

Input the 3rd number: 87

The greatest: 87

You might also like