Groovy web console

subscribe to the feed Subscribe
to this
site
Class Marksheet (via #groovywebconsole)
tweet this snippet Tweet
this
script

Class Marksheet

Published 2 months ago by Anshuk with tags Groovy
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
class Student{int StudentID, Mark1, Mark2, Mark3;
String StudentName;
//method for Mark Total
def Total(){
    def total = Mark1+Mark2+Mark3,
        Name = StudentName, 
        Id = StudentID;
return "Student ID: " + Id + "\nStudent Name: " + Name + "\nTotal Marks: " + total ;
};
static void main(String[] args){
Student st = new Student();
st.StudentID = 1;
st.StudentName = "Ankit Chauhan";
st.Mark1 = 40
st.Mark2 = 50
st.Mark3 = 80
println(st.Total())
Student st2 = new Student();
st.StudentID = 2;
st.StudentName = "Ankit Shroti";
st.Mark1 = 40
st.Mark2 = 70
st.Mark3 = 80
println(st.Total())
}
}