[Go to site: main page, start]

0% found this document useful (0 votes)
4 views2 pages

Java Programs

The document contains multiple Java programs that demonstrate basic input and output operations. It includes examples for reading a number from the user, calculating the sum of two integers, multiplying two floating-point numbers, and determining if a number is even or odd. Each program showcases fundamental programming concepts using the Java language.

Uploaded by

SNS ZARIFA
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)
4 views2 pages

Java Programs

The document contains multiple Java programs that demonstrate basic input and output operations. It includes examples for reading a number from the user, calculating the sum of two integers, multiplying two floating-point numbers, and determining if a number is even or odd. Each program showcases fundamental programming concepts using the Java language.

Uploaded by

SNS ZARIFA
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

import [Link].

Scanner;
public class HelloWorld {
public static void main(String[] args) {
Scanner reader = new Scanner([Link]);
[Link]("Enter a number: ");
int number = [Link]();
[Link]("You entered: " + number);
}
}

class Main {
public static void main(String[] args) {
int first = 10;
int second = 20;
int sum = first + second;
[Link](first + " + " + second + " = " + sum);
}
}
public class MultiplyTwoNumbers {
public static void main(String[] args) {
float first = 1.5f;
float second = 2.0f;
float product = first * second;
[Link]("The product is: " + product);
}
}

import [Link];
public class EvenOdd {
public static void main(String[] args) {
Scanner reader = new Scanner([Link]);
[Link]("Enter a number: ");
int num = [Link]();
if(num % 2 == 0)
[Link](num + " is even");
else
[Link](num + " is odd");
}
}

You might also like