Java 7 To 10 Program Manual
Java 7 To 10 Program Manual
Enrollment no,name,marks of subject 1, subject2 , subject 3, total marks. Total of the three marks
be calculated only when the student passes in all athe three subject. The pass marks for each
subject is 50. If candidate fails in any one subject his total marks must be declared as zero(0), using
this condition write a constructor for this class . write separate functions for accepting & displaying
students details. In the main method create an array of three students objects and display the
details.
import java.util.Scanner;
class Student {
String studentName;
String registrationNumber;
Student(String name, String regno, int m1, int m2, int m3) {
studentName = name;
registrationNumber = regno;
sub1 = m1;
sub2 = m2;
sub3 = m3;
void display() {
total = 0;
} else {
}
}
class StudentDemo {
name = in.nextLine();
in.nextLine();
in.nextLine();
in.nextLine();
students[i].display();
}
OUTPUT
Enter the details of 3 students
likhith b
0079
29
49
50
mayur jadav
0101
99
100
98
lokesh
0089
100
100
49
Information of Students1
name=likhith b
registor number=0079
Information of Students2
name=mayur jadav
registor number=0101
subject one marks=99
Information of Students3
name=lokesh
registor number=0089
8. In a college First year classes are havig the following name of the class (BCA ,B Com,BSc),name
of the staff ,no of the students in the class. Array of student in class
import java.util.Scanner;
class College{
String cname,staffname;
int num;
cname=name;
staffname=sname;
num=n;
void display(){
System.out.println("Class name="+cname);
System.out.println("Staff Name="+staffname);
System.out.println("number of Students="+num);
}
}
class Cdemo{
int n, i=0;
for( i=0;i<3;i++){
name = in.nextLine();
sname=in.nextLine();
n=in.nextInt();
in.nextLine();
for( i=0;i<3;i++){
c[i].display();
OUTPUT:
Enter the details
DATA STRUCTURES
REKHA MAAM
57
JAVA
RASHMI MAAM
57
MATHEMATICS
BHAVANA MAAM
57
number of Students=57
Class name=JAVA
number of Students=57
Class name=MATHEMATICS
number of Students=57
9. Define a class called first year with above attributes ad define a suitable constructor. Also write a
method called best Studet() which process a first-year object and return the student with the
highest total marks. In the main method define a first-year object and find the best student of the
class.
import java.util.Scanner;
class College{
String cname,staffname;
int num;
cname=name;
staffname=sname;
num=n;
}
void display(){
System.out.println("Class name="+cname);
System.out.println("Staff Name="+staffname);
System.out.println("number of Students="+num);
class Cdemo{
int n, i=0;
for( i=0;i<3;i++){
name = in.nextLine();
sname=in.nextLine();
n=in.nextInt();
in.nextLine();
for( i=0;i<3;i++){
c[i].display();
OUTPUT:
Enter the Details of the Three Students :
Enter name,regno,m1,m2,m3
likhith
100
99
87
67
Enter name,regno,m1,m2,m3
mayur
88
89
99
100
Enter name,regno,m1,m2,m3
lokesh
100
100
100
99
NAME=lokeshHIGHSCORE=299
10. Program to define a class called employee with the name and state of appointment. Create ten
employee objects or an array and sort them as per their date of appontment i.e., print them as per
the time seniorty.
import java.util.*;
import java.io.*;
class Emp{
String name,date;
this.name=name;
this.date = date;
return a.date.compareTo(b.date);
list.add(new Emp("RAJU","2020-03-19"));
list.add(new Emp("SANJANA","2019-02-27"));
list.add(new Emp("RAM","2019-01-27"));
list.add(new Emp("ARUN","1998-02-26"));
list.add(new Emp("VELAN","2023-09-15"));
list.add(new Emp("ASHOK","2023-08-16"));
list.add(new Emp("PRAJAN","2023-05-17"));
list.add(new Emp("CHETHAN","2022-05-18"));
list.add(new Emp("HARSHITHA","2023-06-17"));
list.add(new Emp("PALLAVI","2024-01-15"));
System.out.println("BEFORE SORTING:");
for(Emp d:list)
System.out.println(d.name+"\t"+d.date);
Collections.sort(list,new Sort());
for(Emp d:list)
System.out.println(d.name+"\t"+d.date);
}
OUTPUT
BEFORE SORTING:
RAJU 2020-03-19
SANJANA 2019-02-27
RAM 2019-01-27
ARUN 1998-02-26
VELAN 2023-09-15
ASHOK 2023-08-16
PRAJAN 2023-05-17
CHETHAN 2022-05-18
HARSHITHA 2023-06-17
PALLAVI 2024-01-15
ARUN 1998-02-26
RAM 2019-01-27
SANJANA 2019-02-27
RAJU 2020-03-19
CHETHAN 2022-05-18
PRAJAN 2023-05-17
HARSHITHA 2023-06-17
ASHOK 2023-08-16
VELAN 2023-09-15
PALLAVI 2024-01-15