Define a class Student described as below:
Instance variables:
name,age,m1,m2,m3,max,
avg
Member methods:
void accept (): Enter the name,age and marks of a student.
void compute(): To compute the average and maximum out of three marks
void display (): To display all the details.
Write a main () function to create an object of class and call the above methods.
import java.util.*;
class Student
{
String name;
int age,m1,m2,m3,max;
double avg;
void accept()
{
Scanner ob=new Scanner (System.in);
System.out.println("Enter the name of the student");
name=ob.nextLine();
System.out.println("Enter the marks for 3 subjects")
m1=ob.nextInt();
m2=ob.nextInt();
m3=ob.nextInt();
}
void compute()
{
max=Math.max(m1, Math.max(m2,m3));
avg=(m1+m2+m3)/3.0;
}
void display()
{
System.out.println("The name is"+name)
System.out.println("The age is"+age)
System.out.println("The Marks in three subjects are"+m1+""+m2""+m3);
System.out.println("The average marks are:"+avg);
System.out.println("The maximum Marks is:"+max);
}
void main()
{
Student ob1= new Student();
ob1.accept();
ob1.compute();
ob1.display();
}
}