Future Vision BIE Future Vision BIE


ONE STOP FOR ALL STUDY MATERIALS & LAB PROGRAMS


E MENU Whatsapp Share Join Telegram, to get Instant Updates
× NOTE! Click on MENU to Browse between Subjects...

Advertisement

DESIGN AND ANALYSIS OF ALGORITHMS LABORATORY

(Effective from the academic year 2018 -2019)

SEMESTER - IV

Course Code 18CSL47

CIE Marks 40

Number of Contact Hours/Week 0:2:2

SEE Marks 60

Total Number of Lab Contact Hours 36

Exam Hours 03



Experiments 2A

Write a Java program to implement the Stack using arrays. Write Push(), Pop() & Display() methods to demonstrate its working



Advertisement

Advertisement

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//package twoA;
import java.util.Scanner;

class staff
{
	public static Scanner scan= new Scanner(System.in);
	int staffid;
	String name,phno;
	double sal;
	void get_info()
	{
		System.out.println("Enter in order \nStaff ID : Name : Phone Number : Salary :");
		staffid=scan.nextInt();
		name=scan.next();
		phno=scan.next();
		sal=scan.nextDouble();
	}
	void display()
	{
		System.out.println("Staff Details:\nStaff Id : "+staffid+"\nName :"+name+"\nPhone Number : "+phno+"\nSalary : "+sal);
	}
}
class Teaching extends staff
{
	public static Scanner scan= new Scanner(System.in);
	String domain,pub;
	void get_info()
	{
		super.get_info();
		System.out.println("Enter the Domain of Teacher "+name+" in order\nDomain : Publication");
		domain=scan.next();
		pub=scan.next();
	}
	void display()
	{
		super.display();
		System.out.println("Domain : "+domain+"\nPublication :"+pub);
	}
}
class Technical extends Teaching
{
	public static Scanner scan= new Scanner(System.in);
	String skills;
	void get_info()
	{
		super.get_info();
		System.out.println("Enter the Skills for Teacher "+name);
		skills=scan.next();
	}
	void display()
	{
		super.display();
		System.out.println("Skills :"+skills);
	}
}
class Contact extends Technical
{
	public static Scanner scan= new Scanner(System.in);
	String period;
	void get_info()
	{
		super.get_info();
		System.out.println("Enter the periods handled by Teacher "+name);
		period=scan.next();
	}
	void display()
	{
		super.display();
		System.out.println("Period : "+period);
	}
}

public class College {
	public static Scanner scan= new Scanner(System.in);
	public static void main(String[] args) {
		int n;
		System.out.println("Enter the Total Number of Records");
		n=scan.nextInt();
		Contact c[] = new Contact[n];
		for(int i=0;i<n;i++)
		{
			c[i]=new Contact();
			int r=i+1;
			System.out.println("Enter the Details of Record No "+r);
			c[i].get_info();
		}
		for(int i=0;i<n;i++)
		{
			int r=i+1;
			System.out.println("Displaying record No :"+r);
			c[i].display();
		}
	}
}

Advertisement

output
Fig 2.1: Output .

Advertisement
× Note Please Share the website link with Your Friends and known Students...

-ADMIN

× Note Page Number is specified to navigate between Pages...
T = Text book
QB = Question Bank
AS = Amswer Script


-ADMIN

Advertisement