posted Aug 22, 2012, 10:32 AM by Neil Mathew
[
updated Aug 22, 2012, 10:36 AM
]
SOURCE CODE:
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
| import java.io.*;
class StudentRecord
{
String name;
String rollno;
double marks[] = new double[3];
double avg;
void getdata() throws IOException
{
InputStreamReader ir=new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(ir);
System.out.print("\n\n Enter the Name:");
name = br.readLine();
System.out.print("\n Enter the RollNo:");
rollno=br.readLine();
System.out.print("\n Enter the Marks of Maths:");
marks[0] = Double.parseDouble(br.readLine());
System.out.print("\n Enter the Marks of Physics:");
marks[1] = Double.parseDouble(br.readLine());
System.out.print("\n Enter the Marks of Chemistry:");
marks[2] = Double.parseDouble(br.readLine());
}
void setdata()
{
avg=0;
for(int i=0; i<3; i++)
avg += marks[i];
avg/=3;
}
void display()
{
System.out.println("\n\n Name:"+name);
System.out.println(" RollNo:"+rollno);
System.out.println("\n Marks of Maths:"+marks[0]);
System.out.println(" Marks of Physics:"+marks[1]);
System.out.println(" Marks of Chemistry:"+marks[2]);
System.out.println("\n Average Marks:"+avg);
}
}
public class Record
{
public static void main(String args[]) throws IOException
{
StudentRecord obj=new StudentRecord();
obj.getdata();
obj.setdata();
obj.display();
}
}
|
OUTPUT:
C:\Java 1.6\jdk1.6.0_30\bin\src3>javac Record.java
C:\Java 1.6\jdk1.6.0_30\bin\src3>java Record
Enter the
Name:Neil
Enter the
RollNo:3305
Enter the
Marks of Maths:85
Enter the
Marks of Physics:80
Enter the
Marks of Chemistry:90
Name:Neil
RollNo:3305
Marks of
Maths:85.0
Marks of
Physics:80.0
Marks of
Chemistry:90.0
Average
Marks:85.0
|
|
|