Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

Student Name:Bipandeep Singh Pannu

UID:20BCS6809
Branch: CSE(AIML)
Section/Group:AIML4-B
Semester:3 Date of Performance:08-10-
2021

1. Aim/Overview of the practical :Write a program in java that implements


interface Student which has two methods
Display_Grade and Attendance for PG_Students and UG_Students
(PG_Students and UG_Students are two different classes for Post Graduate
and Under Graduate Students respectively).
2. Task to be done:
To create interface for displaying attendance and grade of PG and UG
students.
3. Apparatus:

1. System with any Operating System.


2. Jdk
3. Ide or any other Texteditor

4. Algorithm/Flowchart (For programming based labs):

1. Create a interface class


2. Create two abstract method for grade and attendance respectively inside
interface.
3. Create a class which inherite the properties of interface class.
4. Now give the functions to those abstract classes.
5. Create a main class and initialize the value there.
6. Create the objets of the methods.
7. Exit.

5. Theme/Interests definition( For creative domains):


Interface: An interface is a abstract class that is used to group related
methods
with empty bodies.
Java:-Java is a class-based, object-oriented programming language that
isdesigned to have as few implementation dependencies as possible.
Java Class:-
Java is an object-oriented programming language. Everything in Java is
associated with classes and objects, along with its attributes and methods. ... A
Class is like an object constructor, or a "blueprint" for creating objects.

6. Steps for experiment/practical:


Step1-Open Ide “Eclipse ide”.
Step2-Left click on file form menu tab.
Step 3-Select new Java project.
Step 4-Click on project and select package.
Step 5-Click on package select new class.
Step 6-Now you successfully create class,start programming.

PROGRAM:

interface Student
{
void Display_Grade();
void Display_Atten();
}
class PG_Student implements Student
{
String name, grade;
int m1, m2, m3, attendence, total;
PG_Student(String name, int m1, int m2, int m3, int attendence)
{
this.name = name;
this.m1 = m1;
this.m2 = m2;
this.m3 = m3;
this.attendence = attendence;
}
void Display()
{
System.out.println("Name is " + name);
System.out.println("Marks are " + m1 + " " + m2 + " " + m3);
}
public void Display_Atten()
{
System.out.println("The attendence is " + attendence);
}
public void Display_Grade()
{
total = m1 + m2 + m3;
if (total > 250)
{
grade = "A";
}
else if (total < 250)
{
grade = "B";
} else if (total < 200)
{
grade = "C";
}
else
{
grade = "D";
}
System.out.println("The Grade is " + grade);
}
}
class UG_Student implements Student
{
String name, grade;
int m1, m2, m3, attendence, total;
UG_Student(String name, int m1, int m2, int m3, int attendence)
{
this.name = name;
this.m1 = m1;
this.m2 = m2;
this.m3 = m3;
this.attendence = attendence;
}
void Display()
{
System.out.println("Name is " + name);
System.out.println("Marks are " + m1 + " " + m2 + " " + m3);
}
public void Display_Atten()
{
System.out.println("The attendence is " + attendence);
}
public void Display_Grade()
{
total = m1 + m2 + m3;
if (total > 300)
{
grade = "S";
}
else if (total > 250)
{
grade = "A";
}
else if (total < 250)
{
grade = "B";
}
else if (total < 200)
{
grade = "C";
}
else
{
grade = "D";
}
System.out.println("The Grade is " + grade);
}
}
class Demo {
public static void main(String[] args) {
PG_Student pg = new PG_Student("Alex", 45, 68, 47, 35);
pg.Display();
pg.Display_Atten();
pg.Display_Grade();
UG_Student ug = new UG_Student("Aman", 95, 88, 77, 25);
ug.Display();
ug.Display_Atten();
ug.Display_Grade();
}
}

7. Observations/Discussions(For applied/experimental sciences/materials


based labs):
In this program we observe the range of grade put by the user and the uses of
interface.

8. Percentage error (if any or applicable):


There is no percentage error.

9. Result/Output/Writing Summary:

You might also like