Ashley P.

asked • 06/22/20

Java Classes & Objects

How do we calculate the average marks of s, s1, s2 & s3



class Test{


public static void main(String args[]){

Student s;

s = new Student();

s.name='A';

s.age=23;

s.marksMaths=67;

s.marksEnglish=84;

System.out.println(s.name);

System.out.println(s.age);

System.out.println(s.marksMaths);

System.out.println(s.marksEnglish);

System.out.println(s.average);


Student s1;

s1 = new Student();

s1.name='B';

s1.age=34;

s1.marksMaths=45;

s1.marksEnglish=88;


Student s2;

s2 = new Student();

s2.name='C';

s2.age=22;

s2.marksMaths=29;

s2.marksEnglish=93;


Student s3;

s3 = new Student();

s3.name='D';

s3.age=17;

s3.marksMaths=74;

s3.marksEnglish=38;


}


}


1 Expert Answer

By:

Patrick B. answered • 06/23/20

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.