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 1A

Create a Java class called Student with the following details as variables within it.
i.USN
ii.Name
iii.Branch
iv.Phone



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
import java.util.Scanner;

public class Room {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n,i;
		Student[] s=new Student[100];
		System.out.println("Enter the Number of Objects");
		n=scan.nextInt();
		for(i=0;i<n;i++)
		{
			s[i]=new Student();
		}
		for(i=0;i<n;i++)
		{
			System.out.println("Enter the Details in Order - Name , Usn , Branch , Phone No");
			String name = scan.next();
			String usn = scan.next();
			String branch = scan.next();
			String phno = scan.next();
			s[i].assignvalue(name, usn, branch, phno);
		}
		System.out.println("Students Details are as Follow:");
		for(i=0;i<n;i++)
		{
			s[i].display();
		}
		scan.close();
	}
}
class Student
{
	String name,usn,branch,phno;
	void assignvalue(String n,String u,String b,String p)
	{
		name=n;
		usn=u;
		branch=b;
		phno=p;
	}
	void display()
	{
		System.out.println("Name :"+name+" USN :"+usn+" Branch :"+branch+"Phone Number :"+phno);
	}
}

Advertisement

output
Fig 1.1: Output .

Advertisement

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