/*4.Program to create a student class with following attributes;
Enrollment No: Name, Mark of sub1, Mark of sub2, mark of sub3, Total Marks. Total
of the three marks must be calculated only when the student passes in all three
subjects. The pass mark for each subject is 50. If a candidate fails in any one of the
subjects his total mark must be declared as zero. Using this condition write a
constructor for this class. Write separate functions for accepting and displaying
student details. In the main method create an array of n student objects and display
the details..*/
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class PROGRAM4
{
public static void main(String[] args)
{
int n, total = 0, flag=0;
String name;
try{
BufferedReader reader =new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter student Name : ");
name=reader.readLine();
Scanner s = new Scanner(System.in);
System.out.print("Marks of 3 subject:");
int marks[] = new int[3];
System.out.println("Enter marks out of 100:");
for(int i = 0; i < 3; i++)
{
marks[i] = s.nextInt();
if(marks[i]<50)
flag=1;
total = total + marks[i];
}
student s1=new student(name,marks[0],marks[1],marks[2]);
if(flag==1){
total=0;
System.out.println("student is Failed in one of subject total mark is Reduced to Zero : "+total);
}
else
{
System.out.println("student Optained total marks : "+total);
}
}catch(Exception e){
}
}
}
class student{
public int m1,m2,m3;
String name;
public int Total;
public student(String name,int m1,int m2,int m3){
this.m1=m1;
this.m2=m2;
this.m3=m3;
this.name=name;
}
}