Skip to content

Commit 2b9a5f9

Browse files
committed
Almost working, stupid string thingy fucking up
1 parent 82688e6 commit 2b9a5f9

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

for_loop/ClassTeacher.java

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import java.util.Scanner;
2+
3+
public class ClassTeacher {
4+
public static void main(String[] args) {
5+
Scanner x = new Scanner(System.in);
6+
String name[] = new String[5],s="";
7+
int marks[][] = new int[5][5],si=0,c=0;
8+
for(int i=0; i<5; i++)
9+
{
10+
name[i] = x.nextLine();
11+
}
12+
System.out.println("Enter marks in this order: English,Maths,Physics,Chemistry,Computer");
13+
for(int i=0; i<5; i++)
14+
{
15+
for(int j =0;j<5;j++)
16+
{
17+
marks[i][j] = x.nextInt();
18+
}
19+
}
20+
System.out.print("Enter the student name: ");
21+
s = x.nextLine();
22+
for(int i =0; i<5; i++)
23+
{
24+
if(name[i].equalsIgnoreCase(s)){
25+
si=i;
26+
c++;
27+
break;
28+
}
29+
}
30+
if(c==1)
31+
{
32+
for(int j=0;j<5;j++)
33+
{
34+
System.out.println(marks[si][j]);
35+
}
36+
}
37+
else
38+
{
39+
System.out.println("Element not found");
40+
}
41+
}
42+
}

0 commit comments

Comments
 (0)