Write a Program to calculate the marksheet of students
This example is about built a marksheet of student using java. In this example,
Member Variable : roll_no, sub1, sub2, sub3, sub4, sub5, total, avg
Member Function : getStudentData() , calculateTotal() , calculateAvg(), displayStudentData()
getStudentData() function is used to get all information for the student. calculateTotal() function is used to calculate total of all subjects of marks. calculateAvg() function is used to count average of all subjects. displayStudentData() function is used to display the student information.
File Name : studDetail.java
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 | import java.io.*; class stud { int roll_no,sub1,sub2,sub3,sub4,sub5,total,avg; String name; public void getStudentData() throws Exception { System.out.println("Enter Roll No. :-"); DataInputStream in = new DataInputStream(System.in); roll_no = Integer.parseInt(in.readLine()); System.out.println("Enter Name :-"); name = in.readLine(); System.out.println("Enter Subject 1 Mark :-"); sub1 = Integer.parseInt(in.readLine()); System.out.println("Enter Subject 2 Mark :-"); sub2 = Integer.parseInt(in.readLine()); System.out.println("Enter Subject 3 Mark :-"); sub3 = Integer.parseInt(in.readLine()); System.out.println("Enter Subject 4 Mark :-"); sub4 = Integer.parseInt(in.readLine()); System.out.println("Enter Subject 5 Mark :-"); sub5 = Integer.parseInt(in.readLine()); } public void calculateTotal() throws Exception { total = sub1+sub2+sub3+sub4+sub5; } public void calculateAvg() throws Exception { avg = total/5; } public void displayStudent() throws Exception { System.out.println("Roll No. :"+roll_no); System.out.println("Name :"+name); System.out.println("Subject 1 Mark :"+sub1); System.out.println("Subject 2 Mark :"+sub2); System.out.println("Subject 3 Mark :"+sub3); System.out.println("Subject 4 Mark :"+sub4); System.out.println("Subject 5 Mark :"+sub5); System.out.println("Total :"+total); System.out.println("Average :"+avg); } } class studDetail { public static void main(String args[]) throws Exception { stud s1 = new stud(); s1.getStudentData(); s1.calculateTotal(); s1.calculateAvg(); s1.displayStudent(); } } |
Output :
Enter Roll No. :- 1
Enter Name :- XYZ
Enter Subject 1 Mark : 70
Enter Subject 2 Mark : 80
Enter Subject 3 Mark : 90
Enter Subject 4 Mark : 60
Enter Subject 5 Mark : 50
//display information like this format
Roll No. :1
Name :XYZ
Subject 1 Mark : 70
Subject 2 Mark : 80
Subject 3 Mark : 90
Subject 4 Mark : 60
Subject 5 Mark : 50
Total : 350
Average : 70
GTU Java Practical, Java Program, Java Tutorial, Marksheet of students in java, student marksheet in java, Write a Program to calculate the marksheet of students
0 comments:
Post a Comment