Student marks calculation program in Java

By: Paawan Chaudhary Emailed: 1644 times Printed: 2112 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

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();
	}
}

Java Home | All Java Tutorials | Latest Java Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.



Bookmark and Share

Comments(8)


1. View Comment

import java.lang.*;
import java.io.*;
class student
{
String sname;
int stno,m1,m2,m3,total;
void read()
{
try
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter stno");
int stno=Integer.parseInt(br.readLine());
System.out.println("enter sname");
sname=br.readLine();
System.out.println("enter m1");
int m1=Integer.parseInt(br.readLine());
System.out.println("enter m2");
int m2=Integer.parseInt(br.readLine());
System.out.println("enter m3");
int m3=Integer.parseInt(br.readLine());
}
catch(Exception e)
{
}
}
void display()
{
System.out.println("\n student details");
System.out.println("\n stno :"+stno);
System.out.println("\n sname :"+sname);
System.out.println("\n m1 :"+m1);
System.out.println("\n m2 :"+m2);
System.out.println("\n m3 :"+m3);
System.out.println("\n total :"+calctot());
}
int calctot()
{
return(m1+m2+m3);
}
public static void main(String args[])
{
student s=new student();
s.read();
s.display();
}
}


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

while compiling above program, iam getting this ERROR as given below:
""""""""""""
Student.java:12: error: constructor BufferedReader in class BufferedReader canno
t be applied to given types;
BufferedReader br = new BufferedReader(new InputStreamReader(Sys
tem.in));
^
required: no arguments
found: InputStreamReader
reason: actual and formal argument lists differ in length

""""""""""""""


View Tutorial          By: ss chary at 2013-07-15 08:06:18
3. View Comment

write a program to prepare the student marks for six subject list with following requirements.
a) get the name of the student and marks for six subjects.
b) caculate the total,average and grade of the student.
c) display the name,marks,total,average and grade.


View Tutorial          By: belgreen frodo at 2015-03-31 05:41:05
4. View Comment

write the program to convert the following:
a) From Kina (PKG) to Australian dollar(AUD)
b) US dollar (USD) to Kina (PKG)


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

I very grateful with this program it expand my idea on java programming. best regard to you all.

View Tutorial          By: Nuhu Abdullahi at 2015-06-13 11:42:38
6. View Comment

Well the code is good but what if students start entering marks above 100 like 1244 or 121 e.t.c how could we check that and make the input console available for the user to enter the correct marks than move further

View Tutorial          By: nitin kumar sharma at 2015-07-15 06:58:18
7. View Comment

Pastoral College is a small college in the Midwest.
Create a program that accept a student's data:
an ID number, first and last name,
major field of study, and grade point average.
Display a student's data if the student's
grade point average is below 2.0 (ex. 1.75, 1.50)


View Tutorial          By: James Chui at 2015-08-03 00:48:50
8. View Comment

If I want to read input from A PDF what should I do?

View Tutorial          By: thiru at 2015-08-12 10:57:51

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:



More Tutorials by Paawan Chaudhary
Count number of vowels, consonants and digits in a String in Java
Reverse a number in Java
Student marks calculation program in Java
Handling Fractions in Java
Calculate gross salary in Java
Calculate average sale of the week in Java
Vector in Java - Sample Program
MultiLevel Inheritance sample in Java
Multiple Inheritance sample in Java
Java program using Method Overriding
Java program to check if user input is an even number
Java program to print prime numbers using Thread
Java program to calculate volume of a Box
Java program to display numbers from 1 to 10 on Applet
Draw a bar chart in Java

More Tutorials in Java
Update contents of a file within a jar file
Tomcat and httpd configured in port 8080 and 80
Java File
Java String
Count number of vowels, consonants and digits in a String in Java
Reverse a number in Java
Student marks calculation program in Java
Handling Fractions in Java
Calculate gross salary in Java
Calculate average sale of the week in Java
Vector in Java - Sample Program
MultiLevel Inheritance sample in Java
Multiple Inheritance sample in Java
Java program using Method Overriding
Java program to check if user input is an even number

More Latest News
Most Viewed Articles (in Java )
How to Send SMS using Java Program (full code sample included)
InetAddress Example program in Java
Student marks calculation program in Java
Count number of vowels, consonants and digits in a String in Java
Execute system commands in a Java Program
Write to a file in Java - Sample Program
Stack example in Java - push(), pop(), empty(), search()
What is Java?
FileReader and FileWriter example program in Java
Integer: byte, short, int, and long data types in Java
wait(), notify() and notifyAll() in Java - A tutorial
Multidimensional or arrays of arrays in Java
indexOf( ) and lastIndexOf( ) in Java
XML and Java - Parsing XML using Java Tutorial
Recursion in java
Most Emailed Articles (in Java)
What is Multithreaded programming?
TCP Server and TCP Client in Java
Read from a COM port using Java program
Type Casting in Java
setPriority() and getPriority() in Java
? - ternary (three-way) operator - in Java
Using One-Dimensional Arrays in Java
constants and variables
Why java is important to the Internet
Java program for Associate keys with values
Of Object, equals (), == and hashCode ()
Basics of Exception Handling in Java
Basics of Inheritance in Java
for loop in java
left shift operator, <<, in Java