
Create a class called Student which has the following methods:
i. Average: which would accept marks of 3 examinations & return whether the student has passed or failed depending on whether he has scored an average above 50 or not.
ii. Inputname: which would accept the name of the student & returns the name.

Hi Friend,
Try the following code:
import java.util.*;
public class Student{
Scanner input=new Scanner(System.in);
public String average(){
System.out.print("Enter Marks1: ");
double m1=input.nextDouble();
System.out.print("Enter Marks2: ");
double m2=input.nextDouble();
System.out.print("Enter Marks3: ");
double m3=input.nextDouble();
double tm=m1+m2+m3;
double avg=tm/3;
if(avg<50){
return "Failed";
}
if(avg>50){
return "Passed";
}
return " ";
}
public String getName(){
System.out.println("Enter Name:");
String name=input.nextLine();
String result=average();
return name+" get "+result;
}
public static void main(String[]args){
Student data=new Student();
String nameAndResut=data.getName();
System.out.println(nameAndResut);
}
}
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.