0% found this document useful (0 votes)
59 views

Java Lab 5

The document contains the code for a Java program that defines classes to store student details like personal information, academic performance, placement details, and extracurricular activities. It takes user input for 3 students and stores it in arrays of each class type. It then takes a registration number as input and displays the details of the matching student from each class.

Uploaded by

Yukti Satheesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views

Java Lab 5

The document contains the code for a Java program that defines classes to store student details like personal information, academic performance, placement details, and extracurricular activities. It takes user input for 3 students and stores it in arrays of each class type. It then takes a registration number as input and displays the details of the matching student from each class.

Uploaded by

Yukti Satheesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

GYANADIPTA MOHANTY 

19BCE1224
JAVA PROGRAMING
LAB 5
4-3-2021

1. 
Define a class University that has 2 member variables name of the university and
place. Define a method display to print the university details. Construct an interface
that method called subject() which is implemented into a class called School. Given
the name of the university, display the details and the subjects offered by them.

2.

Main.java

package MainPack;

import java.util.*;

import Pack1.*;

import Pack2.*;

import Pack3.*;

import Pack2.nonacad.*;

public class Main

{
public static void main(String[] args)

Scanner sc = new Scanner(System.in);

detail[] stu = new detail[3];

academic[] aca = new academic[3];

nonacd[] non = new nonacd[3];

placement[] pla = new placement[3];

int r,m,p, reg;

String n, g, c, gr, cmp, s;

for(int i=0; i<3; i++) {

stu[i] = new detail();

aca[i] = new academic();

non[i] = new nonacd();

pla[i] = new placement();

System.out.println("Student Reg : ");

r = sc.nextInt();

System.out.println("Student Name : ");

n = sc.next();

System.out.println("Gender : ");

g = sc.next();

System.out.println("Course : ");

c = sc.next();

System.out.println("Marks : ");

m = sc.nextInt();

System.out.println("Grade : ");

gr = sc.next();

System.out.println("Sports : ");

s = sc.next();

System.out.println("Company : ");

cmp = sc.next();
System.out.println("Package : ");

p = sc.nextInt();

stu[i].get(r, n, g);

aca[i].get(r, m, gr, c);

non[i].get(r, s);

pla[i].get(r, cmp, p);

reg = sc.nextInt();

for(int i=0; i<3; i++) {

if(reg == stu[i].reg) {

stu[i].display();

if(reg == aca[i].reg) {

aca[i].display();

if(reg == non[i].reg) {

non[i].display();

if(reg == pla[i].reg) {

pla[i].display();

Detail.java

package Pack1;

import java.util.*;

/**
*

* @author Gyanadipta Mohanty

*/

public class detail

public int reg;

String name;

String gender;

public void get(int r, String n, String g) {

reg = r;

name = n;

gender = g;

public void display() {

System.out.println("Student Reg : " + reg);

System.out.println("Student Name : " + name);

System.out.println("Gender : " + gender);

Academic.java

package Pack2;

import java.util.*;

public class academic {

public int reg;

int marks;

String grade;

String course;

public void get(int r, int m, String g, String c) {


reg = r;

course = c;

marks = m;

grade = g;

public void display() {

System.out.println("Course : " + course);

System.out.println("Marks : " + marks);

System.out.println("Grade : " + grade);

Placement.java

package Pack3;

import java.util.*;

/**

* @author Gyanadipta Mohanty

*/

public class placement {

public int reg;

String company;

int pack;

public void get(int r, String c, int p) {

reg = r;

company = c;

pack = p;

public void display() {

System.out.println("Company : " + company);


System.out.println("Package : " + pack);

Nonacd.java

package Pack2.nonacad;

import java.util.*;

public class nonacd {

public int reg;

String sports;

public void get(int r, String s) {

reg = r;

sports = s;

public void display() {

System.out.println("Sports : " + sports);

You might also like