Java Program For Student Info

class Student
{
 String name;
 String rollno;
 int sub1,sub2,sub3,sub4;
Student(String nm,String no,int s1,int s2, int s3, int s4)
{
  this.name=nm;
  this.rollno=no;
  this.sub1=s1;
  this.sub2=s2;
  this.sub3=s3;
  this.sub4=s4;
}

 int total()
 {
  return sub1+sub2+sub3+sub4;
 }
}

class StudentDemo
{
 public static void main(String args[])
{
  int tot;
 Student st1= new Student("Rao","12001100",90,90,90,90);
 Student st2= new Student("Rajan","12001101",80,50,80,80);
 
  tot= st1.total();
 System.out.println(st1.name + "total marks = " +tot);

 tot= st2.total();
 System.out.println(st2.name + "total marks = " +tot);
}
}

 
Bhanu Namikaze

Bhanu Namikaze is an Ethical Hacker, Web Developer, Student and Mechanical Engineer. He Enjoys writing articles, Blogging, Solving Errors and Social Networking. Feel Free to let me know any of your concerns about hacking or let me know if you need any more methods on hacking anything. Enjoy Learning

No comments:

Post a Comment