-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIfelse_pg.java
More file actions
50 lines (49 loc) · 2.3 KB
/
Copy pathIfelse_pg.java
File metadata and controls
50 lines (49 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*This Java program consists of commented-out code blocks for various challenges */
/*Uncomment the part you want to use */
import java.util.Scanner;
public class Ifelse_pg {
public static void main(String[] args) {
Scanner sk= new Scanner(System.in);
/*challenge B:Prompt user to enter a number and classify it as positive, negative, or neither.*/
// System.out.print("Enter any number: ");
// int a=sk.nextInt();
// if(a<0) System.out.println("Negative number");
// else if (a>0) System.out.println("Positive number");
// else System.out.println("It is Neither");
/* challenge B:Prompt user to enter a number and determine if it's even or odd.8/
// System.out.print("Enter any number: ");
// int eo=sk.nextInt();
//
// if(eo%2==0){
// System.out.println("It is an even number");
// }
// else System.out.println("It is an odd ");
// }
/*challenge C:Prompt user to enter three numbers
and identify if they are equal or find the largest among them.*/
// System.out.println("Enter Any three numbers");
// System.out.print("Number one: ");
// int n1=sk.nextInt();
// System.out.print("Number two: ");
// int n2=sk.nextInt();
// System.out.print("Number three: ");
// int n3=sk.nextInt();
// if(n1==n2&&n2==n3){System.out.print("All numbers given are equal");}
// int largest=n1;
// if(n2>largest){
// if(n2>n3){
// System.out.println(n2+" is the largest number ");}
// else System.out.println(n3+" is the largest number ");}
// else
// if(n3>largest){
// if(n3>n2){System.out.println(n3+" is the largest number ");}
// else System.out.println(n2+" is the largest number ");}
/*challenge D:Prompt user to enter a year and determine if it's a leap year.*/
// System.out.println("Leap year Identifying Machine ");
// System.out.print("Enter the year to be checked: ");
// int year= sk.nextInt();
// // from ChatGPT
// if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {System.out.println(year+" is a leap year ");}
// else {System.out.println(year+" is not a leap year ");}
}
}