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, Security Analyst, Blogger, Web Developer and a Mechanical Engineer. He Enjoys writing articles, Blogging, Debugging Errors and Capture the Flags. Enjoy Learning; There is Nothing Like Absolute Defeat - Try and try until you Succeed.

No comments:

Post a Comment