0% found this document useful (0 votes)
13 views6 pages

Java If Else Input Q1

The document contains 20 Java programs that perform various checks based on user input. Each program uses conditional statements to determine and print results related to numbers, strings, and age criteria. Examples include checking if a number is zero, if a user is a senior citizen, and validating a password.

Uploaded by

Gee Lucknow
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)
13 views6 pages

Java If Else Input Q1

The document contains 20 Java programs that perform various checks based on user input. Each program uses conditional statements to determine and print results related to numbers, strings, and age criteria. Examples include checking if a number is zero, if a user is a senior citizen, and validating a password.

Uploaded by

Gee Lucknow
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

🔹 1.

Zero Check
import [Link];
public class Q1 {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
int num = [Link]();
if (num == 0) {
[Link]("Zero");
} else {
[Link]("Not Zero");
}
}
}

🔹 2. Greater than 100


import [Link];
public class Q2 {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
int num = [Link]();
if (num > 100) {
[Link]("Greater than 100");
} else {
[Link]("Less or Equal to 100");
}
}
}

🔹 3. Senior Citizen
import [Link];
public class Q3 {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
int age = [Link]();
if (age >= 60) {
[Link]("Senior Citizen");
} else {
[Link]("Not Senior Citizen");
}
}
}

🔹 4. Equal to 10
import [Link];
public class Q4 {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
int num = [Link]();
if (num == 10) {
[Link]("Equal to 10");
} else {
[Link]("Not Equal to 10");
}
}
}

🔹 5. String "yes"
import [Link];
public class Q5 {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
String str = [Link]();
if ([Link]("yes")) {
[Link]("Correct");
} else {
[Link]("Wrong");
}
}
}

🔹 6. Positive or Negative
import [Link];
public class Q6 {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
int num = [Link]();
if (num >= 0) {
[Link]("Positive");
} else {
[Link]("Negative");
}
}
}

🔹 7. Excellent Marks
import [Link];
public class Q7 {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
int marks = [Link]();
if (marks > 90) {
[Link]("Excellent");
} else {
[Link]("Not Excellent");
}
}
}

🔹 8. Divisible by 5
import [Link];
public class Q8 {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
int num = [Link]();
if (num % 5 == 0) {
[Link]("Divisible by 5");
} else {
[Link]("Not Divisible by 5");
}
}
}

🔹 9. Username "student"
import [Link];
public class Q9 {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
String name = [Link]();
if ([Link]("student")) {
[Link]("Welcome Student");
} else {
[Link]("Invalid User");
}
}
}

🔹 10. Salary Check


import [Link];
public class Q10 {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
int salary = [Link]();
if (salary < 20000) {
[Link]("Low Salary");
} else {
[Link]("Good Salary");
}
}
}

🔹 11. Two Numbers Equal


import [Link];
public class Q11 {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
int a = [Link]();
int b = [Link]();
if (a == b) {
[Link]("Equal");
} else {
[Link]("Not Equal");
}
}
}

🔹 12. Freezing Temperature


import [Link];
public class Q12 {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
int temp = [Link]();
if (temp < 0) {
[Link]("Freezing");
} else {
[Link]("Not Freezing");
}
}
}

🔹 13. 3 Digit Number


import [Link];
public class Q13 {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
int num = [Link]();
if (num >= 100 && num <= 999) {
[Link]("3 Digit Number");
} else {
[Link]("Not 3 Digit");
}
}
}

🔹 14. String "India"


import [Link];
public class Q14 {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
String country = [Link]();
if ([Link]("India")) {
[Link]("Correct Country");
} else {
[Link]("Wrong Country");
}
}
}

🔹 15. Height Check


import [Link];
public class Q15 {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
int height = [Link]();
if (height > 150) {
[Link]("Tall");
} else {
[Link]("Short");
}
}
}

🔹 16. Greater than 1


import [Link];
public class Q16 {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
int num = [Link]();
if (num > 1) {
[Link]("Greater than 1");
} else {
[Link]("Not Greater than 1");
}
}
}

🔹 17. Password Check


import [Link];
public class Q17 {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
String pass = [Link]();
if ([Link]("1234")) {
[Link]("Access Granted");
} else {
[Link]("Access Denied");
}
}
}
🔹 18. Even or Odd
import [Link];
public class Q18 {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
int num = [Link]();
if (num % 2 == 0) {
[Link]("Even");
} else {
[Link]("Odd");
}
}
}

🔹 19. Admin Check


import [Link];
public class Q19 {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
String name = [Link]();
if ([Link]("admin")) {
[Link]("Welcome Admin");
} else {
[Link]("Not Admin");
}
}
}

🔹 20. Age Between 18–25


import [Link];
public class Q20 {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
int age = [Link]();
if (age >= 18 && age <= 25) {
[Link]("Between 18 and 25");
} else {
[Link]("Not Between 18 and 25");
}
}
}

You might also like