-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQueueMain.java
162 lines (133 loc) · 3.73 KB
/
QueueMain.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// CLASS OGRENCİ
package ArrayListGeneric;
public class Ogrenci {
private int no;
private String ad;
private String soyad;
private int vize_not;
private int final_not;
private double gecme_notu;
private static int count = 0;
public Ogrenci(String ad, String soyad, int vize_not, int final_not) {
this.no = ++count;
this.ad = ad;
this.soyad = soyad;
this.vize_not = vize_not;
this.final_not = final_not;
this.gecme_notu = ((vize_not * 0.4) + (final_not * 0.6));
}
public int getNo() {
return no;
}
public void setNo(int no) {
this.no = no;
}
public String getAd() {
return ad;
}
public void setAd(String ad) {
this.ad = ad;
}
public String getSoyad() {
return soyad;
}
public void setSoyad(String soyad) {
this.soyad = soyad;
}
public double getGecme_notu() {
return gecme_notu;
}
public void setGecme_notu(double gecme_notu) {
this.gecme_notu = gecme_notu;
}
}
// CLASS MAIN
package ArrayListGeneric;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;
public class QueueMain {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String ad, soyad;
int vize_not, final_not, menu;
boolean dongu = true;
Queue<Ogrenci> liste = new LinkedList<Ogrenci>();
while(dongu)
{
System.out.println("\t\t----------------------------");
System.out.println("\t\t1) Ogrenci Ekle");
System.out.println("\t\t2) Ogrencileri Listele");
System.out.println("\t\t3) Ad Ara");
System.out.println("\t\t4) Ad Sil");
System.out.println("\t\t5) Cikis");
System.out.println("\t\t----------------------------");
System.out.println("Menu giriniz : ");
menu = scanner.nextInt();
switch(menu)
{
case 1:
System.out.println("Ogrenci ad giriniz : ");
ad = scanner.next();
System.out.println("Ogrenci soyad giriniz : ");
soyad = scanner.next();
System.out.println("Ogrenci vize notu giriniz : ");
vize_not = scanner.nextInt();
System.out.println("Ogrenci final notu giriniz : ");
final_not = scanner.nextInt();
Ogrenci ogr = new Ogrenci(ad, soyad, vize_not, final_not);
liste.add(ogr);
break;
case 2:
System.out.println(" -- Ogrenci Bilgileri -- ");
for(Ogrenci ogrenci : liste)
{
System.out.println("NO : " + ogrenci.getNo() +" AD : " + ogrenci.getAd() + " SOYAD : " + ogrenci.getSoyad() + " GECME NOTU : " + ogrenci.getGecme_notu());
}
break;
case 3:
String aranacak;
System.out.println("Aramak istediginiz ogrencinin adini giriniz : ");
aranacak = scanner.next();
int count = 0;
for(Ogrenci ogrenci : liste)
{
if(ogrenci.getAd().equals(aranacak))
{
count++;
System.out.println("Aranan ogrenci bulundu !!");
System.out.println("NO : " + ogrenci.getNo() +" AD : " + ogrenci.getAd() + " SOYAD : " + ogrenci.getSoyad() + " GECME NOTU : " + ogrenci.getGecme_notu());
}
}
if(count == 0)
{
System.out.println("Aranan ogrenci bulunamadý !!");
}
break;
case 4:
String silinecek;
int indis = 0;
System.out.println("Silmek istediginiz ogrencinin adini giriniz : ");
silinecek = scanner.next();
for(Ogrenci ogrenci : liste)
{
if(ogrenci.getAd().equals(silinecek))
{
liste.remove(indis);
}
indis++;
}
break;
case 5:
System.out.println("Cikis yapiliyor ..");
dongu = false;
break;
default:
System.out.println("Gecersiz menu secimi. Lutfen tekrar menu seciniz..");
break;
}
}
}
}