Student marks calculation program in Java

By: Paawan Chaudhary Emailed: 1789 times Printed: 2624 times    

This Java program defines a class student with four data members such as name, roll no,sub1, and sub2. Defines appropriate methods to initialize and displays the values of data members. Also calculates total Marks and percentage scored by the student.

import java.lang.*;
import java.io.*;
class student
{
	String name;
	int roll_no;
	int sub1,sub2;
	int total;
	float per;
	void getdata() throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		System.out.println ("Enter Name of Student");
		name = br.readLine();
		System.out.println ("Enter Roll No. of Student");
		roll_no = Integer.parseInt(br.readLine());
		System.out.println ("Enter marks out of 100 of 1st subject");
		sub1 = Integer.parseInt(br.readLine());
		System.out.println ("Enter marks out of 100 of 2nd subject");
		sub2 = Integer.parseInt(br.readLine());
	}
	void show()
	{
		total=sub1+sub2;
		per=(total*100)/200;
		System.out.println ("Roll No. = "+roll_no);
		System.out.println ("Name = "+name);
		System.out.println ("Marks of 1st Subject = "+sub1);
		System.out.println ("Marks of 2nd Subject = "+sub2);
		System.out.println ("Total Marks = "+total);
		System.out.println ("Percentage = "+per+"%");
	}
}
class q2Student
{
	public static void main(String args[]) throws IOException
	{
		student s=new student();
		s.getdata();
		s.show();
	}
}

Most Viewed Articles (in Java )

Latest Articles (in Java)

Comment on this tutorial

Subscribe to Tutorials

Related Tutorials

Archived Comments

1. import java.lang.*;
import java.io.*;

View Tutorial          By: satya at 2012-12-09 10:57:28

2. while compiling above program, iam getting this ER
View Tutorial          By: ss chary at 2013-07-15 08:06:18

3. write a program to prepare the student marks for s
View Tutorial          By: belgreen frodo at 2015-03-31 05:41:05

4. write the program to convert the following:

View Tutorial          By: belgreen frodo at 2015-03-31 05:53:21

5. I very grateful with this program it expand my ide
View Tutorial          By: Nuhu Abdullahi at 2015-06-13 11:42:38

6. Well the code is good but what if students start e
View Tutorial          By: nitin kumar sharma at 2015-07-15 06:58:18

7. Pastoral College is a small college in the Midwest
View Tutorial          By: James Chui at 2015-08-03 00:48:50

8. If I want to read input from A PDF what should I d
View Tutorial          By: thiru at 2015-08-12 10:57:51

9. After the course code is chosen (input by the user
View Tutorial          By: Nungel at 2015-12-01 07:25:40

10. THIS IS GOOD WEB
View Tutorial          By: MUNNA at 2016-11-14 05:26:31