-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lab2HomeTask4.java
119 lines (95 loc) · 3.49 KB
/
Lab2HomeTask4.java
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import java.util.Scanner;
public class Lab2HomeTask4 {
/*Take three student name id,Section,CGPA,gender from user input
i)Print students id,section if gender is female and name length is 4
ii)Print students name,CGPA if gender is male and start with S*/
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String name1;
String gender1;
int id1;
int section1;
double CGPA1;
String name2;
String gender2;
int id2;
int section2;
double CGPA2;
String name3;
String gender3;
int id3;
int section3;
double CGPA3;
System.out.println("---Enter first Student information ---\n");
System.out.println("Enter first Student Name : ");
name1 = input.nextLine();
System.out.println("Enter first Student ID : ");
id1 = input.nextInt();
input.nextLine();
System.out.println("Enter first Student Section : ");
section1 = input.nextInt();
input.nextLine();
System.out.println("Enter first Student CGPA : ");
CGPA1 = input.nextDouble();
input.nextLine();
System.out.println("Enter first Student Gender : ");
gender1 = input.next();
System.out.println("\n---Student1 information Display---\n");
if (gender1.equals("female") && name1.length() == 4) {
System.out.println("Student1 ID : " + id1);
System.out.println("Student1 Section :" + section1);
}
else if (gender1.equals("male") && name1.charAt(0) == 'S') {
System.out.println("Student1 Name : " + name1);
System.out.println("Student1 CGPA : " + CGPA1);
}
System.out.println("\n---Enter Second Student information ---\n");
System.out.println("Enter Second Student Name : ");
name2 = input.nextLine();
input.nextLine();
System.out.println("Enter Second Student ID : ");
id2 = input.nextInt();
input.nextLine();
System.out.println("Enter Second Student Section : ");
section2 = input.nextInt();
input.nextLine();
System.out.println("Enter Second Student CGPA : ");
CGPA2 = input.nextDouble();
input.nextLine();
System.out.println("Enter Second Student Gender : ");
gender2 = input.nextLine();
if (gender2.equals("female") && name2.length() == 4) {
System.out.println("\n---Student2 information Display---\n");
System.out.println("Student2 ID : " + id2);
System.out.println("Student2 Section :" + section2);
}
else if (gender2.equals("male") && name2.charAt(0) == 'S') {
System.out.println("Student2 Name : " + name2);
System.out.println("Student2 CGPA : " + CGPA2);
}
System.out.println("\n---Enter third Student information ---\n");
System.out.println("Enter third Student Name : ");
name3 = input.nextLine();
input.nextLine();
System.out.println("Enter third Student ID : ");
id3 = input.nextInt();
input.nextLine();
System.out.println("Enter third Student Section : ");
section3 = input.nextInt();
input.nextLine();
System.out.println("Enter third Student CGPA : ");
CGPA3 = input.nextDouble();
input.nextLine();
System.out.println("Enter third Student Gender : ");
gender3 = input.nextLine();
System.out.println("\n\n---Student3 information Display---\n");
if (gender3.equals("female") && name3.length() == 4) {
System.out.println("Student3 ID : " + id3);
System.out.println("Student3 Section :" + section3);
}
else if (gender3.equals("male") && name3.charAt(0) == 'S') {
System.out.println("Student1 Name : " + name3);
System.out.println("Student1 CGPA : " + CGPA3);
}
}
}