-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathcode5.java
More file actions
35 lines (32 loc) · 926 Bytes
/
Copy pathcode5.java
File metadata and controls
35 lines (32 loc) · 926 Bytes
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
import java.util.Scanner;
class program{
String name; int teacher_id; String subject;
teacher()
{
Scanner sc = new Scanner(System.in);
System.out.print("\nEnter the name: ");
name=sc.nextLine();
System.out.print("\nEnter teacher id: "); teacher_id=sc.nextInt();
System.out.print("\nChoose the type\n1. Programming\n2.Theory \n");
int opt=sc.nextInt();
if(opt==1)
subject="Java";
else
subject="Discrete Mathematics is ";
}
void output()
{
System.out.println("Name: "+name);
System.out.println("Teacher ID: "+teacher_id);
System.out.println("Subject: "+subject);
}
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
teacher t[]=new teacher[100];
System.out.println("Enter number of teachers (maximum 100): ");
int n=sc.nextInt();
for(int i=0;i<n;i++)
t[i]=new teacher(); for(int i=0;i<n;i++)
t[i].output();
}
}