Skip to content

Commit 0d4fa3d

Browse files
committed
lab_5 initial commit
1 parent 61c9157 commit 0d4fa3d

File tree

23 files changed

+1215
-0
lines changed

23 files changed

+1215
-0
lines changed

src/java_labs/lab_5/Lab.java

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
--||author : codechaser||--
4+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
5+
*/
6+
package java_labs.lab_4;
7+
8+
import java.util.*;
9+
import java.io.*;
10+
11+
public class Lab {
12+
public static void start() {
13+
Scanner input = new Scanner(System.in);
14+
while(true) {
15+
System.out.println("\n\n---------------------------");
16+
System.out.println(" | L A B 5 |");
17+
System.out.println("---------------------------\n");
18+
System.out.println("[01] : Problem 1");
19+
System.out.println("[02] : Problem 2");
20+
System.out.println("[03] : Problem 3");
21+
System.out.println("[04] : Problem 4");
22+
System.out.println("[05] : Problem 5\n");
23+
System.out.println("[-1] : Exit\n");
24+
System.out.println("---------------------------\n");
25+
System.out.println("Enter your choice :\n");
26+
int choice = input.nextInt();
27+
System.out.println("\n---------------------------\n");
28+
if (choice == -1) {
29+
System.out.println("Exiting...\n");
30+
System.out.println("---------------------------\n");
31+
return;
32+
}
33+
switch (choice) {
34+
case 1:
35+
java_labs.lab_4.problem_1.Problem1.start();
36+
break;
37+
case 2:
38+
java_labs.lab_4.problem_2.Problem2.start();
39+
break;
40+
case 3:
41+
java_labs.lab_4.problem_3.Problem3.start();
42+
break;
43+
case 4:
44+
java_labs.lab_4.problem_4.Problem4.start();
45+
break;
46+
case 5:
47+
java_labs.lab_4.problem_5.Problem5.start();
48+
break;
49+
default:
50+
System.out.println("\nInvalid Choice");
51+
}
52+
System.out.println("\n---------------------------\n");
53+
}
54+
}
55+
56+
public static void main(String[] args){
57+
start();
58+
return;
59+
}
60+
}
61+
/*
62+
|---------------------------------------------------|
63+
||| https://codeforces.com/profile/codechaser |||
64+
||| https://www.codechef.com/users/codechaser |||
65+
||| https://github.com/code-chaser |||
66+
|---------------------------------------------------|
67+
*/
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
/*
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
--||author : codechaser||--
4+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
5+
*/
6+
package java_labs.lab_4.problem_1;
7+
8+
import java.util.*;
9+
import java.io.*;
10+
import java_labs.lab_4.problem_1.MCA.Student;
11+
12+
public class Problem1 {
13+
public static void start() {
14+
int students = 0;
15+
Vector<Student> studentsList = new Vector<Student>(1);
16+
while (true) {
17+
Scanner input = new Scanner(System.in);
18+
System.out.println("\n\n---------------------------");
19+
System.out.println(" S C H O O L");
20+
System.out.println("---------------------------\n");
21+
System.out.println("[01] : Add a new student");
22+
System.out.println("[02] : Update a students' marks");
23+
System.out.println("[03] : Print a student's details");
24+
System.out.println("[04] : Print all students' details\n");
25+
System.out.println("[-1] : Exit\n");
26+
System.out.println("---------------------------\n");
27+
System.out.println("Enter your choice :\n");
28+
int choice = input.nextInt();
29+
String temp = input.nextLine();
30+
System.out.println("\n---------------------------\n");
31+
if (choice == -1) {
32+
System.out.println("Exiting...\n");
33+
System.out.println("---------------------------\n");
34+
return;
35+
}
36+
String name;
37+
int roll, standard;
38+
double totalMarks, percentage, marksA, marksB, marksC, marksD, marksE;
39+
switch (choice) {
40+
case 1:
41+
System.out.println("\nEnter Student's Name: ");
42+
name = input.nextLine();
43+
System.out.println("\nEnter Student's Standard: ");
44+
standard = input.nextInt();
45+
temp = input.nextLine();
46+
System.out.println("\nNOTE: Enter all marks out of 100");
47+
System.out.println("\nEnter Student's marks in Computer Science: ");
48+
marksA = input.nextDouble();
49+
temp = input.nextLine();
50+
System.out.println("\nEnter Student's marks in Mathematics: ");
51+
marksB = input.nextDouble();
52+
temp = input.nextLine();
53+
System.out.println("\nEnter Student's marks in Physics: ");
54+
marksC = input.nextDouble();
55+
temp = input.nextLine();
56+
System.out.println("\nEnter Student's marks in Chemistry: ");
57+
marksD = input.nextDouble();
58+
temp = input.nextLine();
59+
System.out.println("\nEnter Student's marks in English: ");
60+
marksE = input.nextDouble();
61+
temp = input.nextLine();
62+
students++;
63+
Student S = new Student(name, students, standard, marksA, marksB, marksC, marksD, marksE);
64+
studentsList.add(S);
65+
System.out.println("\n" + name + " successfully added, their Roll Number is " + students + ".");
66+
System.out.println("\n---------------------------\n");
67+
break;
68+
case 2:
69+
System.out.println("\nEnter Student's Roll Number: ");
70+
roll = input.nextInt();
71+
temp = input.nextLine();
72+
if (roll < 1 || roll > students) {
73+
System.out.println("\nInvalid Roll Number!");
74+
System.out.println("\n---------------------------\n");
75+
break;
76+
}
77+
System.out.println("\nNOTE: Enter all marks out of 100");
78+
System.out.println("\nEnter Student's marks in Computer Science: ");
79+
marksA = input.nextDouble();
80+
temp = input.nextLine();
81+
System.out.println("\nEnter Student's marks in Mathematics: ");
82+
marksB = input.nextDouble();
83+
temp = input.nextLine();
84+
System.out.println("\nEnter Student's marks in Physics: ");
85+
marksC = input.nextDouble();
86+
temp = input.nextLine();
87+
System.out.println("\nEnter Student's marks in Chemistry: ");
88+
marksD = input.nextDouble();
89+
temp = input.nextLine();
90+
System.out.println("\nEnter Student's marks in English: ");
91+
marksE = input.nextDouble();
92+
temp = input.nextLine();
93+
studentsList.get(roll - 1).updateMarks(marksA, marksB, marksC, marksD, marksE);
94+
System.out.println("\nMarks updated successfully!");
95+
System.out.println("\n---------------------------\n");
96+
break;
97+
case 3:
98+
System.out.println("\nEnter Student's Roll Number: ");
99+
roll = input.nextInt();
100+
temp = input.nextLine();
101+
if (roll < 1 || roll > students) {
102+
System.out.println("\nInvalid Roll Number!");
103+
System.out.println("\n---------------------------\n");
104+
break;
105+
}
106+
System.out.println("\nDetails: \n");
107+
studentsList.get(roll - 1).display();
108+
totalMarks = studentsList.get(roll - 1).marksA + studentsList.get(roll - 1).marksB
109+
+ studentsList.get(roll - 1).marksC + studentsList.get(roll - 1).marksD
110+
+ studentsList.get(roll - 1).marksE;
111+
percentage = totalMarks / 5;
112+
System.out.print("\nTotal Marks: " + totalMarks);
113+
System.out.print("\nPercentage: " + percentage + "\n");
114+
System.out.println("\n---------------------------\n");
115+
break;
116+
case 4:
117+
System.out.println("\nDetails: \n");
118+
for (int i = 0; i < students; i++) {
119+
studentsList.get(i).display();
120+
totalMarks = studentsList.get(i).marksA + studentsList.get(i).marksB
121+
+ studentsList.get(i).marksC + studentsList.get(i).marksD + studentsList.get(i).marksE;
122+
percentage = totalMarks / 5;
123+
System.out.print("\nTotal Marks: " + totalMarks);
124+
System.out.print("\nPercentage: " + percentage + "\n");
125+
}
126+
System.out.println("\n--------------------------\n");
127+
break;
128+
default:
129+
System.out.println("\nInvalid Choice");
130+
System.out.println("\n---------------------------\n");
131+
}
132+
}
133+
}
134+
135+
public static void main(String[] Args) {
136+
start();
137+
return;
138+
}
139+
}
140+
/*
141+
|---------------------------------------------------|
142+
||| https://codeforces.com/profile/codechaser |||
143+
||| https://www.codechef.com/users/codechaser |||
144+
||| https://github.com/code-chaser |||
145+
|---------------------------------------------------|
146+
*/
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
--||author : codechaser||--
4+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
5+
*/
6+
package java_labs.lab_5.problem_1.citizen;
7+
8+
import java.util.*;
9+
import java.io.*;
10+
11+
public class Student {
12+
private String name = "";
13+
private int roll, standard;
14+
public double marksA, marksB, marksC, marksD, marksE;
15+
16+
public Student(String name, int roll, int standard, double marksA, double marksB, double marksC, double marksD,
17+
double marksE) {
18+
this.name = name;
19+
this.roll = roll;
20+
this.standard = standard;
21+
this.marksA = marksA;
22+
this.marksB = marksB;
23+
this.marksC = marksC;
24+
this.marksD = marksD;
25+
this.marksE = marksE;
26+
}
27+
28+
public void updateMarks(double marksA, double marksB, double marksC, double marksD, double marksE) {
29+
this.marksA = marksA;
30+
this.marksB = marksB;
31+
this.marksC = marksC;
32+
this.marksD = marksD;
33+
this.marksE = marksE;
34+
return;
35+
}
36+
37+
public void display() {
38+
System.out.print("\n\nName: " + this.name);
39+
System.out.print("\nRoll Number: " + this.roll);
40+
System.out.print("\nStandard: " + this.standard);
41+
System.out.print("\nMarks in Computer Science: " + this.marksA);
42+
System.out.print("\nMarks in Mathematics: " + this.marksB);
43+
System.out.print("\nMarks in Physics: " + this.marksC);
44+
System.out.print("\nMarks in Chemistry: " + this.marksD);
45+
System.out.print("\nMarks in English: " + this.marksE + "\n\n");
46+
return;
47+
}
48+
}
49+
/*
50+
|---------------------------------------------------|
51+
||| https://codeforces.com/profile/codechaser |||
52+
||| https://www.codechef.com/users/codechaser |||
53+
||| https://github.com/code-chaser |||
54+
|---------------------------------------------------|
55+
*/
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
--||author : codechaser||--
4+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
5+
*/
6+
package java_labs.lab_4.problem_2;
7+
8+
import java.util.*;
9+
import java.io.*;
10+
import java_labs.lab_4.problem_2.car.Car;
11+
import java_labs.lab_4.problem_2.vehicle.Vehicle;
12+
13+
public class Problem2 {
14+
public static void start() {
15+
Car car = new Car("52WVC10338", "2.7L 4X2 MT Fortuner", "Toyota", "MKCL287987463892", "SUV", 7);
16+
Vehicle vehicle = new Vehicle("83WST28493", "10L Crusher Truck", "Mahindra", "JUYN287987463343");
17+
while (true) {
18+
Scanner input = new Scanner(System.in);
19+
double a, b;
20+
System.out.println("\n\n---------------------------");
21+
System.out.println("\n V E H I C L E S\n");
22+
System.out.println("---------------------------\n");
23+
System.out.println("[01] : Print Car Details");
24+
System.out.println("[02] : Print Vehicle Details\n");
25+
System.out.println("[-1] : Exit\n");
26+
System.out.println("---------------------------\n");
27+
System.out.println("Enter your choice :\n");
28+
int choice = input.nextInt();
29+
String temp = input.nextLine();
30+
System.out.println("\n---------------------------\n");
31+
if (choice == -1) {
32+
System.out.println("Exiting...\n");
33+
System.out.println("---------------------------\n");
34+
return;
35+
}
36+
switch (choice) {
37+
case 1:
38+
car.display();
39+
System.out.print("\n---------------------------\n");
40+
break;
41+
case 2:
42+
vehicle.display();
43+
System.out.print("\n---------------------------\n");
44+
break;
45+
default:
46+
System.out.println("\nInvalid Choice");
47+
System.out.println("\n---------------------------\n");
48+
break;
49+
}
50+
}
51+
}
52+
53+
public static void main(String[] Args) {
54+
start();
55+
return;
56+
}
57+
}
58+
/*
59+
|---------------------------------------------------|
60+
||| https://codeforces.com/profile/codechaser |||
61+
||| https://www.codechef.com/users/codechaser |||
62+
||| https://github.com/code-chaser |||
63+
|---------------------------------------------------|
64+
*/
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
--||author : codechaser||--
4+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
5+
*/
6+
package java_labs.lab_4.problem_2.car;
7+
8+
import java.util.*;
9+
import java.io.*;
10+
import java_labs.lab_4.problem_2.vehicle.Vehicle;
11+
12+
public class Car extends Vehicle {
13+
private String type;
14+
private int capacity;
15+
16+
public Car(String engine, String model, String manufacturer, String chassis, String type, int capacity) {
17+
super(engine, model, manufacturer, chassis);
18+
this.type = type;
19+
this.capacity = capacity;
20+
}
21+
22+
public void display() {
23+
super.display();
24+
System.out.print("\nType: " + this.type);
25+
System.out.print("\nCapacity: " + this.capacity + "-seater\n\n");
26+
return;
27+
}
28+
}
29+
/*
30+
|---------------------------------------------------|
31+
||| https://codeforces.com/profile/codechaser |||
32+
||| https://www.codechef.com/users/codechaser |||
33+
||| https://github.com/code-chaser |||
34+
|---------------------------------------------------|
35+
*/

0 commit comments

Comments
 (0)