-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.java
More file actions
143 lines (140 loc) · 2.94 KB
/
Test.java
File metadata and controls
143 lines (140 loc) · 2.94 KB
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
import java.util.Scanner;
class Person
{
String name;
int age;
static Scanner sc=new Scanner(System.in);
void setPerson()
{
System.out.println("Enter the name of the Person: ");
name=sc.next();
System.out.println("Enter the age of the person: ");
age=sc.nextInt();
}
void getPerson()
{
System.out.println("NAME= " + name);
System.out.println("AGE= " + age);
}
}
class Student extends Person
{
int id,sub1,sub2,sub3;
String branch;
void setStudent()
{
setPerson();
System.out.println("Enter the id of the Student: ");
id=sc.nextInt();
System.out.println("Enter the branch of the Student: ");
branch=sc.next();
System.out.println("Enter the marks of subject 1: ");
sub1=sc.nextInt();
System.out.println("Enter the marks of subject 2: ");
sub2=sc.nextInt();
System.out.println("Enter the marks of subject 3: ");
sub3=sc.nextInt();
}
void getStudent()
{
getPerson();
System.out.println("ID = " + id);
System.out.println("BRANCH = " + branch);
System.out.println("MARKS 1 = " + sub1);
System.out.println("MARKS 2 = " + sub2);
System.out.println("MARKS 3 = " + sub3);
}
int sum()
{
return(sub1+sub2+sub3);
}
}
class Faculty extends Person
{
int exp,no_of_hrs;
String dept;
void setFaculty()
{
setPerson();
System.out.println("Enter the experience years: ");
exp=sc.nextInt();
System.out.println("Enter the department name: ");
dept=sc.next();
System.out.println("Enter the no of hours: ");
no_of_hrs=sc.nextInt();
}
void getFaculty()
{
getPerson();
System.out.println("EXPERIENCE = " + exp);
System.out.println("DEPARTMENT = " + dept);
System.out.println("NO OF HOURS = " + no_of_hrs);
}
int salary()
{
return(no_of_hrs*300);
}
}
/*class Test
{
public static void main(String args[])
{
int n,i;
System.out.println("How many persons details you want to add ? ");
n=Student.sc.nextInt();
Student s[] = new Student[n];
System.out.println("You have entered the details of " + n + " no of persons ");
for(i=0;i<n;i++)
{
System.out.println("Enter the details of Person no: " + (i+1));
for(i=0;i<n;i++)
{
s[i]=new Student();
int total=s[i].sum();
System.out.println("The sum of marks = " + total);
}
Faculty f[]= new Faculty[n];
for(i=0;i<n;i++)
{
f[i]=new Faculty();
f[i].setFaculty();
f[i].getFaculty();
f[i].salary();
}
}
}
}*/
class Test
{
public static void main(String args[])
{
int n,i;
System.out.println("How many persons details you want to add ? ");
n=Student.sc.nextInt();
Student s[] = new Student[n];
System.out.println("You have entered the details of " + n + " no of persons ");
for(i=0;i<n;i++)
{
System.out.println("Enter the details of Person no: " + (i+1));
s[i]=new Student();
s[i].setStudent();
int total=s[i].sum();
System.out.println("The sum of marks = " + total);
}
Faculty f[]= new Faculty[n];
for(i=0;i<n;i++)
{
f[i]=new Faculty();
f[i].setFaculty();
f[i].salary();
}
for(i=0;i<n;i++)
{
s[i].getStudent();
}
for(i=0;i<n;i++)
{
f[i].getFaculty();
}
}
}