0% found this document useful (0 votes)
4 views1 page

Java Programs: Even/Odd & Largest Number

Uploaded by

rabhisikta92
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 views1 page

Java Programs: Even/Odd & Largest Number

Uploaded by

rabhisikta92
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

2.

Check Even or Odd


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

3. Find the Largest of Three Numbers


import [Link];
class LargestNumber {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter first number: ");
int num1 = [Link]();
[Link]("Enter second number: ");
int num2 = [Link]();
[Link]("Enter third number: ");
int num3 = [Link]();int largest = (num1 > num2) ? (num1 > num3 ? num1 : num3) :
(num2 > num3 ? num2 : num3);
[Link]("The largest number is: " + largest);
}
}

You might also like