100% found this document useful (1 vote)
790 views8 pages

JAVA Cycle Sheet 3 CSE1007

The document describes a Java program that creates a database of student details using an array of objects, and allows fetching various lists of students by criteria like year of joining, age range, GPA, residence type. It includes a Student class to store details, and a main class to get input, run the different listing methods simultaneously on multiple threads without interrupting each other.

Uploaded by

aadarsh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
790 views8 pages

JAVA Cycle Sheet 3 CSE1007

The document describes a Java program that creates a database of student details using an array of objects, and allows fetching various lists of students by criteria like year of joining, age range, GPA, residence type. It includes a Student class to store details, and a main class to get input, run the different listing methods simultaneously on multiple threads without interrupting each other.

Uploaded by

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

19BCE2168 Aadarsh N Prasad

Question:

1. Create database of the student with the details such as (name, registernumber,
cgpa, age, dayscholar/hosteller).
2. Create a class student with the needed attributes. Use array of objects to store ‘n’
number of students’ details into the database.
3. Write a java program to fetch the following details from the database.
a. List of students whose joined in 2018.
b. List of students whose age is between 18-20
c. List of students with CGPA less than 5.
d. List of students who stay in hostel.
e. List of 2019 batch students who are dayscholars.

Code:

import java.io.*;

import java.util.Scanner;

class student {

public String name[][] = new String[10][10];

void getDetails(int n)

Scanner get = new Scanner(System.in);

int limit=n;

System.out.println("Enter "+limit+" Student Details\n");

for(int i=0;i<limit;i++)

System.out.println("Enter Name, Roll Number, CGPA, Age & Residence:");

for(int j=0;j<5;j++)

name[i][j] = get.nextLine();

}
19BCE2168 Aadarsh N Prasad

display(limit);

void display(int limit)

System.out.println("Student
Name"+"\t"+"Roll"+"\t\t"+"CGPA"+"\t\t"+"Age"+"\t\t"+"Residence");

for(int i=0;i<limit;i++)

for(int j=0;j<5;j++)

System.out.print(name[i][j]+"\t\t");

System.out.println();

void join2018(int limit)

System.out.println("Student
Name"+"\t"+"Roll"+"\t\t"+"CGPA"+"\t\t"+"Age"+"\t\t"+"Residence");

for(int i=0;i<limit;i++)

if("18".equals(name[i][1].substring(0,2)))

for(int j=0;j<5;j++)

System.out.print(name[i][j]+"\t\t");

void agegap(int limit)


19BCE2168 Aadarsh N Prasad

System.out.println("Student
Name"+"\t"+"Roll"+"\t\t"+"CGPA"+"\t\t"+"Age"+"\t\t"+"Residence");

for(int i=0;i<limit;i++)

if(Integer.parseInt(name[i][3])<=20 && Integer.parseInt(name[i][3])>=18)

for(int j=0;j<5;j++)

System.out.print(name[i][j]+"\t\t");

void gpa(int limit)

System.out.println("Student
Name"+"\t"+"Roll"+"\t\t"+"CGPA"+"\t\t"+"Age"+"\t\t"+"Residence");

for(int i=0;i<limit;i++)

if(Integer.parseInt(name[i][2])<=5)

for(int j=0;j<5;j++)

System.out.print(name[i][j]+"\t\t");

void hostel(int limit)

System.out.println("Student
Name"+"\t"+"Roll"+"\t\t"+"CGPA"+"\t\t"+"Age"+"\t\t"+"Residence");

for(int i=0;i<limit;i++)

if("y".equals(name[i][4]) || "Y".equals(name[i][4]))

for(int j=0;j<5;j++)
19BCE2168 Aadarsh N Prasad

System.out.print(name[i][j]+"\t\t");

void day19(int limit)

System.out.println("Student
Name"+"\t"+"Roll"+"\t\t"+"CGPA"+"\t\t"+"Age"+"\t\t"+"Residence");

for(int i=0;i<limit;i++)

if(("n".equals(name[i][4]) || "Y".equals(name[i][4]) &&


"19".equals(name[i][1].substring(0,2))))

for(int j=0;j<5;j++)

System.out.print(name[i][j]+"\t\t");

class collegeOffice {

public static void main(String args[]) throws IOException

student std = new student();

int n=0;

Scanner in = new Scanner(System.in);

System.out.println("1.Enter details\n2.2018 batch\n3.Age b/w


18,20\n4.CGPA<5\n5.Hostelers\n6.2019 dayscholars\nEnter choice:");

int c = in.nextInt();

switch(c)

case 1:

System.out.print("Enter Number of Students:");

n = in.nextInt();
19BCE2168 Aadarsh N Prasad

std.getDetails(n);

break;

case 2:

std.join2018(n);

break;

case 3:

std.agegap(n);

break;

case 4:

std.gpa(n);

break;

case 5:

std.hostel(n);

break;

case 6:

std.day19(n);

break;

default:

PrintStream output = new PrintStream(new File("Student.txt"));

output.println("Student
Name"+"\t"+"Roll"+"\t\t"+"CGPA"+"\t\t"+"Age"+"\t\t"+"Hosteler");

output.println("======================================");

for(int i=0;i<n;i++)

for(int j=0;j<3;j++)

output.print(std.name[i][j]+"\t\t");

output.println();

output.println("======================================");

}
19BCE2168 Aadarsh N Prasad

output.close();

Question:

Given a String as input, perform the following 2 tasks by 2 threads simultaneously without
interrupting each other. Find the cipher text by substituting every letter in the String by the next
letter in the alphabet list Eg., If the input string is “program”, output should be “qsphsbn”. Find the
cipher text by substituting every letter in the String by the previous letter in the alphabet list Eg., If
the input string is “program”, output should be “oqnfqzl”. Both cipher text has to appended to the
same file one after the other.

Code:

import java.lang.*;

import java.util.*;

class thread1 extends Thread

char ch;

String d,e;

public void run()

d = multhr.a;

e = "";

for(int i=0;i<d.length();i++)

if(((int)d.charAt(i)>=65 && (int)d.charAt(i)<=89) || ((int)d.charAt(i)>=97 &&


(int)d.charAt(i)<=121))

ch = (char)((int)d.charAt(i)+1);

else if(d.charAt(i)=='z')

ch = 'a';
19BCE2168 Aadarsh N Prasad

else if(d.charAt(i)=='Z')

ch = 'A';

e = e + ch;

System.out.println(e);

class thread2 extends Thread

char ch;

String f,g;

public void run()

f = multhr.a;

g = "";

for(int i=0;i<f.length();i++)

if(((int)f.charAt(i)>=66 && (int)f.charAt(i)<=90) || ((int)f.charAt(i)>=98 &&


(int)f.charAt(i)<=122))

ch = (char)((int)f.charAt(i)-1);

else if(f.charAt(i)=='a')

ch = 'z';

else if(f.charAt(i)=='A')

ch = 'Z';

g = g + ch;

System.out.println(g);

public class multhr


19BCE2168 Aadarsh N Prasad

static String a,b,c;

public static void main(String args[])

Scanner s = new Scanner(System.in);

thread1 t1 = new thread1();

thread2 t2 = new thread2();

System.out.print("Enter a String: ");

a = s.next();

t1.start();

t2.start();

You might also like