Skip to content

Commit 9e014d6

Browse files
committed
added project made using diff class
1 parent 2934322 commit 9e014d6

9 files changed

Lines changed: 401 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package ClassroomSystem;
2+
public class ClassRoom {
3+
4+
Student[] students = new Student[5];
5+
int counts = 0;
6+
7+
void addStudents(Student s){
8+
if(counts >= students.length){
9+
System.out.println("Classroom is full.");
10+
return;
11+
}
12+
students[counts] = s;
13+
counts++;
14+
15+
System.out.println(s.name + " added to classroom." );
16+
}
17+
void showStudens(){
18+
if(counts == 0){
19+
System.out.println("No Studens in classroom yet.");
20+
return;
21+
}
22+
23+
System.out.println("Students in classroom: ");
24+
for (int i = 0 ; i < counts ; i++){
25+
students[i].showInfo();
26+
}
27+
}
28+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package ClassroomSystem;
2+
public class Main {
3+
public static void main(String[] args) {
4+
5+
// Classroom System
6+
7+
ClassRoom room = new ClassRoom();
8+
9+
Student student1 = new Student("Alice", 101);
10+
Student student2 = new Student("Bob", 102);
11+
Student student3 = new Student("Charlie", 103);
12+
13+
System.out.println("-------------------------");
14+
15+
room.addStudents(student1);
16+
room.addStudents(student2);
17+
room.addStudents(student3);
18+
19+
System.out.println("-------------------------");
20+
21+
room.showStudens();
22+
}
23+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package ClassroomSystem;
2+
3+
public class Student {
4+
5+
String name;
6+
int id;
7+
8+
Student(String name , int id){
9+
this.name = name;
10+
this.id = id;
11+
}
12+
13+
void showInfo(){
14+
System.out.println("Name: " + name + " Id: " + id);
15+
}
16+
}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
package ConsoleBankingSystem;
2+
3+
import java.util.Scanner;
4+
5+
public class Main {
6+
7+
public static void main(String[] args) {
8+
9+
// CONSOLE BANKING SYSTEM
10+
11+
Scanner scanner = new Scanner(System.in);
12+
13+
double balance = 15000;
14+
double amount;
15+
int choice;
16+
int transactionCount = 0;
17+
18+
String[] history = new String[100];
19+
transactionCount = scanner.nextInt();
20+
21+
do{
22+
showmanu();
23+
24+
System.out.print("Choose options (1-4): ");
25+
choice = scanner.nextInt();
26+
27+
switch (choice) {
28+
case 1 -> {
29+
System.out.printf("Available balance is: %.2f\n" , balance);
30+
}
31+
32+
case 2 -> {
33+
System.out.print("Enter deposite amount: ");
34+
amount = scanner.nextDouble();
35+
scanner.nextLine();
36+
37+
if(amount > 0) {
38+
balance = deposite(balance, amount);
39+
history[transactionCount] = "Deposite: $" + amount;
40+
transactionCount++;
41+
}
42+
else {
43+
System.out.println("Invalid deposite amount");
44+
}
45+
}
46+
47+
case 3 -> {
48+
System.out.print("Enter amount for withdrawn: ");
49+
amount = scanner.nextDouble();
50+
scanner.nextLine();
51+
52+
if (amount > 0 && amount <= balance) {
53+
balance = withdraw(balance, amount);
54+
history[transactionCount] = "Withdrew: $" + amount;
55+
transactionCount++;
56+
}
57+
else {
58+
System.out.println("Invalid withdrawal amount");
59+
}
60+
}
61+
62+
case 4 -> {
63+
64+
if (transactionCount == 0) {
65+
System.out.println("No transactions yet.");
66+
} else {
67+
System.out.println("---- Transaction History ----");
68+
for (int i = 0; i < transactionCount; i++) {
69+
System.out.println(history[i]);
70+
}
71+
}
72+
}
73+
74+
case 5 -> System.out.println("Thank you for coming! Have a good day!");
75+
76+
default -> System.out.println("Invalid choice!");
77+
78+
}
79+
}
80+
while (choice != 5);
81+
82+
scanner.close();
83+
84+
}
85+
static void showmanu() {
86+
87+
System.out.println("--------------------------");
88+
System.out.println("Welcome to BANKING SYSTEM ");
89+
System.out.println("--------------------------");
90+
91+
System.out.println("1. Check balance");
92+
System.out.println("2. Deposite");
93+
System.out.println("3. Withdraw");
94+
System.out.println("4. History");
95+
System.out.println("5. Exit");
96+
}
97+
98+
static double deposite (double balance , double amount){
99+
100+
balance += amount;
101+
System.out.println("Amount added to your account.");
102+
103+
return balance;
104+
}
105+
106+
static double withdraw (double balance , double amount){
107+
108+
balance -= amount;
109+
System.out.println("Amount withdrawn successfully from your account.");
110+
111+
return balance;
112+
}
113+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package LibrarySystem;
2+
public class Book {
3+
4+
String title;
5+
int id;
6+
7+
Book(String bookName , int id){
8+
this.title = bookName;
9+
this.id = id;
10+
}
11+
12+
void showInfo(){
13+
System.out.println("Title: " + title + " Id: " + id);
14+
}
15+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package LibrarySystem;
2+
public class Library {
3+
4+
Book [] book = new Book[5];
5+
int count = 0;
6+
7+
void addBooks(Book b){
8+
if(count >= book.length){
9+
System.out.println("Library is full.");
10+
return;
11+
}
12+
13+
book[count] = b;
14+
count++;
15+
16+
System.out.println(b.title + " Title added to library.");
17+
}
18+
19+
void showBooks(){
20+
21+
if (count == 0){
22+
System.out.println("No books in library.");
23+
return;
24+
}
25+
System.out.println("Books in library:");
26+
for(int i = 0; i < count; i++){
27+
book[i].showInfo();
28+
}
29+
}
30+
void removeBooks(int id){
31+
32+
for (int i = 0; i < count; i++){
33+
if(book[i].id == id){
34+
35+
for (int j = i; j < count - 1; j++) {
36+
book[j] = book[j + 1];
37+
}
38+
39+
book[count - 1] = null;
40+
count--;
41+
42+
System.out.println("Removed Book from library.");
43+
return;
44+
45+
}
46+
}
47+
48+
System.out.println("Book not found.");
49+
50+
}
51+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package LibrarySystem;
2+
3+
public class Main {
4+
5+
public static void main(String[] args) {
6+
7+
// Library System
8+
9+
Library library = new Library();
10+
11+
Book book1 = new Book("Java Basics", 1);
12+
Book book2 = new Book("OOP Concepts", 2);
13+
Book book3 = new Book("Data Structures", 3);
14+
15+
System.out.println("-------------------------------------");
16+
17+
library.addBooks(book1);
18+
library.addBooks(book2);
19+
library.addBooks(book3);
20+
21+
System.out.println("-------------------------------------");
22+
23+
library.showBooks();
24+
25+
System.out.println("-------------------------------------");
26+
27+
library.removeBooks(2);
28+
29+
System.out.println("-------------------------------------");
30+
31+
library.showBooks();
32+
33+
System.out.println("-------------------------------------");
34+
}
35+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package MiniUniversityManagementSystem;
2+
public class Main{
3+
4+
public static void main(String[] args) {
5+
6+
// Mini University Management System
7+
8+
Studend s1 = new Studend("Alice Johnson", 20, 101, "Computer Science");
9+
10+
Studend s2 = new Studend("Bob Smith", 21, 102, "Information Technology");
11+
Studend s3 = new Studend("Charlie Brown", 22, 103, "Mathematics");
12+
Studend s4 = new Studend("David Miller", 23, 104, "Physics");
13+
Studend s5 = new Studend("Emma Davis", 19, 105, "Biology");
14+
Studend s6 = new Studend("Liam Wilson", 20, 106, "Engineering");
15+
Studend s7 = new Studend("Sophia Taylor", 21, 107, "Business");
16+
Studend s8 = new Studend("Noah Anderson", 22, 108, "Chemistry");
17+
Studend s9 = new Studend("Olivia Thomas", 23, 109, "Psychology");
18+
Studend s10 = new Studend("Ethan Moore", 20, 110, "Economics");
19+
20+
System.out.println("--------------------------------");
21+
s1.addFriend(s1);
22+
System.out.println("--------------------------------");
23+
s1.addFriend(s2);
24+
System.out.println("--------------------------------");
25+
s1.addFriend(s3);
26+
System.out.println("--------------------------------");
27+
s1.addFriend(s4);
28+
System.out.println("--------------------------------");
29+
s1.addFriend(s5);
30+
System.out.println("--------------------------------");
31+
s1.addFriend(s6);
32+
System.out.println("--------------------------------");
33+
s1.addFriend(s7);
34+
System.out.println("--------------------------------");
35+
s1.addFriend(s8);
36+
System.out.println("--------------------------------");
37+
s1.addFriend(s9);
38+
System.out.println("--------------------------------");
39+
s1.addFriend(s10);
40+
41+
System.out.println("--------------------------------");
42+
43+
s1.displayInfo();
44+
System.out.println("--------------------------------");
45+
s2.displayInfo();
46+
System.out.println("--------------------------------");
47+
s3.displayInfo();
48+
System.out.println("--------------------------------");
49+
s4.displayInfo();
50+
System.out.println("--------------------------------");
51+
s5.displayInfo();
52+
System.out.println("--------------------------------");
53+
s6.displayInfo();
54+
System.out.println("--------------------------------");
55+
s7.displayInfo();
56+
System.out.println("--------------------------------");
57+
s8.displayInfo();
58+
System.out.println("--------------------------------");
59+
s9.displayInfo();
60+
System.out.println("--------------------------------");
61+
s10.displayInfo();
62+
System.out.println("--------------------------------");
63+
64+
s1.showFriend();
65+
}
66+
}

0 commit comments

Comments
 (0)