Skip to content

Instantly share code, notes, and snippets.

@laxmankumar2000
Created January 27, 2021 15:27
Show Gist options
  • Save laxmankumar2000/f0be2219dab29b06f7f3672a89bc55ab to your computer and use it in GitHub Desktop.
Save laxmankumar2000/f0be2219dab29b06f7f3672a89bc55ab to your computer and use it in GitHub Desktop.
Student
package Student;
import java.util.Scanner;
public class Student {
private int StuRollNo; //Instance Variable
private String StuName;
private int Sub1;
private int SUb2;
private int Sub3;
public Student(int Roll , String Name , int sub1 , int SUb2 , int Sub3 ) //Constractor
{
StuRollNo = Roll;
StuName = Name;
this.Sub1 = sub1;
this.SUb2 = SUb2;
this.Sub3 = Sub3;
}
public int getStuRollNo() {
return StuRollNo;
} // geeter and Setter Method
public void setStuRollNo(int stuRollNo) {
StuRollNo = stuRollNo;
}
public String getStuName() {
return StuName;
}
public void setStuName(String stuName) {
StuName = stuName;
}
public int getSub1() {
return Sub1;
}
public void setSub1(int sub1) {
Sub1 = sub1;
}
public int getSUb2() {
return SUb2;
}
public void setSUb2(int SUb2) {
this.SUb2 = SUb2;
}
public int getSub3() {
return Sub3;
}
public void setSub3(int sub3) {
Sub3 = sub3;
}
}
class Student_Main //Main Classs
{
public static void main(String[] args) {
Scanner obj = new Scanner(System.in);
Student arr[] = new Student[2]; //Non Priitive Array
for (int i = 0; i < arr.length; i++) {
System.out.println("Enter the Roll No. , Name , Mark of Sub1 Sub2 Sub3 ");
arr[i] = new Student(obj.nextInt(),obj.next(),obj.nextInt(), obj.nextInt(), obj.nextInt());
}
// Fpor loop for Count Fail sub...
for (int j = 0; j < arr.length; j++) {
int count = 0;
if (arr[j].getSub1()<40)
{
count++;
}
if (arr[j].getSUb2()<40)
{
count++;
}
if (arr[j].getSub3()<40)
{
count++;
}
System.out.println(arr[j].getStuName() + " is Fail on " + count + " Sub");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment