SlideShare a Scribd company logo
/**
* @author
*
*/
public class Person
{
String sname, iname;
int fid, sid;
}
/**
* @author
*
*/
public class Student extends Person
{
String sname;
int sid;
int no_of_credits, tot_grade_pts;
/**
* @param sname
* @param sid
*/
public Student(String sname, int sid)
{
this.sname = sname;
this.sid = sid;
}
/**
* @return
*/
public String get_name()
{
return sname;
}
public int get_sid()
{
return sid;
}
public boolean two_equal(int sid)
{
if ((this.sid) == sid)
return true;
else
return false;
}
public void set_credits(int credits)
{
no_of_credits = credits;
}
public int get_credits()
{
return no_of_credits;
}
public void set_tot_gpts(int gpts)
{
tot_grade_pts = gpts;
}
public int get_tgpts()
{
return tot_grade_pts;
}
public float get_GPA()
{
return ((tot_grade_pts) / (no_of_credits));
}
}
/**
* @author
*
*/
public class Instructor extends Person
{
String iname;
int fid;
String dept;
/**
* @param iname
* @param fid
*/
public Instructor(String iname, int fid)
{
this.iname = iname;
this.fid = fid;
}
/**
* @param dept
*/
void set_dept(String dept)
{
this.dept = dept;
}
/**
* @return
*/
public String get_dept()
{
return dept;
}
}
import java.util.ArrayList;
/**
* @author
*
*/
public class Course
{
String cname, instructor_name;
int creg_code, max_students, no_of_students;
ArrayList reg_students = new ArrayList();
/**
* @param cname
* @param creg_code
* @param max_students
*/
Course(String cname, int creg_code, int max_students)
{
this.cname = cname;
this.creg_code = creg_code;
this.max_students = max_students;
}
/**
* @param instructor_name
*/
void set_instructor(String instructor_name)
{
this.instructor_name = instructor_name;
}
/**
* method to search student id
*
* @param sid
* @return
*/
public boolean search_student(int sid)
{
if (reg_students.contains(sid))
return true;
else
return false;
}
/**
* method to add student id
*
* @param sid
*/
public void add_student(int sid)
{
try {
if ((reg_students.size()) == max_students)
{
throw new MyException();
}
else
reg_students.add(sid);
}
catch (Exception e)
{
System.out.println("Course has maximum students");
}
}
/**
* method to remove student id
*
* @param sid
*/
public void rem_student(int sid)
{
try {
if (reg_students.contains(sid))
reg_students.remove(new Integer(sid));
else
throw new MyException();
} catch (Exception e)
{
System.out.println("NO STUDENT FOUND WITH THE GIVEN id");
}
}
}
/**
* @author
*
*/
public class MyException extends Exception
{
public MyException() {
// TODO Auto-generated constructor stub
super(" Invalid Data");
}
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Registrar
{
/**
* @param args
* @throws NumberFormatException
* @throws IOException
*/
public static void main(String args[]) throws NumberFormatException,
IOException
{
Course c1 = new Course("default_course", 123, 10);
int ch, regcode, max_stu, sid;
String cname, sname;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
do {
System.out
.println(" 1. create a course 2. add a student 3. remove a student 4. exit");
System.out.print("Enter your choice: ");
ch = Integer.parseInt(br.readLine());
switch (ch)
{
case 1:
System.out.print("Enter course name:");
cname = br.readLine();
System.out.print("Eter registration code :");
regcode = Integer.parseInt(br.readLine());
System.out.print("Enter max students :");
max_stu = Integer.parseInt(br.readLine());
Course c = new Course(cname, regcode, max_stu);
break;
case 2:
System.out.print("Enter student name: ");
sname = br.readLine();
System.out.print("Enter id : ");
sid = Integer.parseInt(br.readLine());
c1.add_student(sid);
break;
case 3:
System.out.print("Enter student id: ");
sid = Integer.parseInt(br.readLine());
c1.rem_student(sid);
break;
}
} while (ch != 4);
}
}
OUTPUT:
1. create a course
2. add a student
3. remove a student
4. exit
Enter your choice: 1
Enter course name:computers
Eter registration code :1211
Enter max students :30
1. create a course
2. add a student
3. remove a student
4. exit
Enter your choice: 2
Enter student name: srinivas
Enter id : 1
1. create a course
2. add a student
3. remove a student
4. exit
Enter your choice: 2
Enter student name: rajesh
Enter id : 2
1. create a course
2. add a student
3. remove a student
4. exit
Enter your choice: 3
Enter student id: 1
1. create a course
2. add a student
3. remove a student
4. exit
Enter your choice: 4
NOTE:
DONT HAVE TIME TO IMPLEMENT SERIALIZATION THINGS
Solution
/**
* @author
*
*/
public class Person
{
String sname, iname;
int fid, sid;
}
/**
* @author
*
*/
public class Student extends Person
{
String sname;
int sid;
int no_of_credits, tot_grade_pts;
/**
* @param sname
* @param sid
*/
public Student(String sname, int sid)
{
this.sname = sname;
this.sid = sid;
}
/**
* @return
*/
public String get_name()
{
return sname;
}
public int get_sid()
{
return sid;
}
public boolean two_equal(int sid)
{
if ((this.sid) == sid)
return true;
else
return false;
}
public void set_credits(int credits)
{
no_of_credits = credits;
}
public int get_credits()
{
return no_of_credits;
}
public void set_tot_gpts(int gpts)
{
tot_grade_pts = gpts;
}
public int get_tgpts()
{
return tot_grade_pts;
}
public float get_GPA()
{
return ((tot_grade_pts) / (no_of_credits));
}
}
/**
* @author
*
*/
public class Instructor extends Person
{
String iname;
int fid;
String dept;
/**
* @param iname
* @param fid
*/
public Instructor(String iname, int fid)
{
this.iname = iname;
this.fid = fid;
}
/**
* @param dept
*/
void set_dept(String dept)
{
this.dept = dept;
}
/**
* @return
*/
public String get_dept()
{
return dept;
}
}
import java.util.ArrayList;
/**
* @author
*
*/
public class Course
{
String cname, instructor_name;
int creg_code, max_students, no_of_students;
ArrayList reg_students = new ArrayList();
/**
* @param cname
* @param creg_code
* @param max_students
*/
Course(String cname, int creg_code, int max_students)
{
this.cname = cname;
this.creg_code = creg_code;
this.max_students = max_students;
}
/**
* @param instructor_name
*/
void set_instructor(String instructor_name)
{
this.instructor_name = instructor_name;
}
/**
* method to search student id
*
* @param sid
* @return
*/
public boolean search_student(int sid)
{
if (reg_students.contains(sid))
return true;
else
return false;
}
/**
* method to add student id
*
* @param sid
*/
public void add_student(int sid)
{
try {
if ((reg_students.size()) == max_students)
{
throw new MyException();
}
else
reg_students.add(sid);
}
catch (Exception e)
{
System.out.println("Course has maximum students");
}
}
/**
* method to remove student id
*
* @param sid
*/
public void rem_student(int sid)
{
try {
if (reg_students.contains(sid))
reg_students.remove(new Integer(sid));
else
throw new MyException();
} catch (Exception e)
{
System.out.println("NO STUDENT FOUND WITH THE GIVEN id");
}
}
}
/**
* @author
*
*/
public class MyException extends Exception
{
public MyException() {
// TODO Auto-generated constructor stub
super(" Invalid Data");
}
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Registrar
{
/**
* @param args
* @throws NumberFormatException
* @throws IOException
*/
public static void main(String args[]) throws NumberFormatException,
IOException
{
Course c1 = new Course("default_course", 123, 10);
int ch, regcode, max_stu, sid;
String cname, sname;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
do {
System.out
.println(" 1. create a course 2. add a student 3. remove a student 4. exit");
System.out.print("Enter your choice: ");
ch = Integer.parseInt(br.readLine());
switch (ch)
{
case 1:
System.out.print("Enter course name:");
cname = br.readLine();
System.out.print("Eter registration code :");
regcode = Integer.parseInt(br.readLine());
System.out.print("Enter max students :");
max_stu = Integer.parseInt(br.readLine());
Course c = new Course(cname, regcode, max_stu);
break;
case 2:
System.out.print("Enter student name: ");
sname = br.readLine();
System.out.print("Enter id : ");
sid = Integer.parseInt(br.readLine());
c1.add_student(sid);
break;
case 3:
System.out.print("Enter student id: ");
sid = Integer.parseInt(br.readLine());
c1.rem_student(sid);
break;
}
} while (ch != 4);
}
}
OUTPUT:
1. create a course
2. add a student
3. remove a student
4. exit
Enter your choice: 1
Enter course name:computers
Eter registration code :1211
Enter max students :30
1. create a course
2. add a student
3. remove a student
4. exit
Enter your choice: 2
Enter student name: srinivas
Enter id : 1
1. create a course
2. add a student
3. remove a student
4. exit
Enter your choice: 2
Enter student name: rajesh
Enter id : 2
1. create a course
2. add a student
3. remove a student
4. exit
Enter your choice: 3
Enter student id: 1
1. create a course
2. add a student
3. remove a student
4. exit
Enter your choice: 4
NOTE:
DONT HAVE TIME TO IMPLEMENT SERIALIZATION THINGS

More Related Content

Similar to @author public class Person{   String sname, .pdf

Java questionI am having issues returning the score sort in numeri.pdf
Java questionI am having issues returning the score sort in numeri.pdfJava questionI am having issues returning the score sort in numeri.pdf
Java questionI am having issues returning the score sort in numeri.pdf
forwardcom41
 
Hello. Im currently working on the last section to my assignment a.pdf
Hello. Im currently working on the last section to my assignment a.pdfHello. Im currently working on the last section to my assignment a.pdf
Hello. Im currently working on the last section to my assignment a.pdf
irshadkumar3
 
Create a class named Student that has the following member variables.pdf
Create a class named Student that has the following member variables.pdfCreate a class named Student that has the following member variables.pdf
Create a class named Student that has the following member variables.pdf
arrowvisionoptics
 
please help with java questionsJAVA CODEplease check my code and.pdf
please help with java questionsJAVA CODEplease check my code and.pdfplease help with java questionsJAVA CODEplease check my code and.pdf
please help with java questionsJAVA CODEplease check my code and.pdf
arishmarketing21
 
HELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdfHELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdf
fatoryoutlets
 
Inheritance 3.pptx
Inheritance 3.pptxInheritance 3.pptx
Inheritance 3.pptx
SamanAshraf9
 
C# programs
C# programsC# programs
C# programs
Gourav Pant
 
JavaExamples
JavaExamplesJavaExamples
JavaExamples
Suman Astani
 
So Far I have these two classes but I need help with my persontest c.pdf
So Far I have these two classes but I need help with my persontest c.pdfSo Far I have these two classes but I need help with my persontest c.pdf
So Far I have these two classes but I need help with my persontest c.pdf
arihantgiftgallery
 
Algoritmos sujei
Algoritmos sujeiAlgoritmos sujei
Algoritmos sujei
gersonjack
 
operating system linux,ubuntu,Mac Geometri.pdf
operating system linux,ubuntu,Mac Geometri.pdfoperating system linux,ubuntu,Mac Geometri.pdf
operating system linux,ubuntu,Mac Geometri.pdf
aquadreammail
 
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDBTDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
tdc-globalcode
 
How to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy CodeHow to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy Code
Daniel Wellman
 
BasicPizza.javapublic class BasicPizza { Declaring instance .pdf
BasicPizza.javapublic class BasicPizza { Declaring instance .pdfBasicPizza.javapublic class BasicPizza { Declaring instance .pdf
BasicPizza.javapublic class BasicPizza { Declaring instance .pdf
ankitmobileshop235
 
Kotlin Data Model
Kotlin Data ModelKotlin Data Model
Kotlin Data Model
Kros Huang
 
Exercises of java tutoring -version1
Exercises of java tutoring -version1Exercises of java tutoring -version1
Exercises of java tutoring -version1Uday Sharma
 
Listing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdfListing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdf
Ankitchhabra28
 

Similar to @author public class Person{   String sname, .pdf (20)

Java questionI am having issues returning the score sort in numeri.pdf
Java questionI am having issues returning the score sort in numeri.pdfJava questionI am having issues returning the score sort in numeri.pdf
Java questionI am having issues returning the score sort in numeri.pdf
 
Hello. Im currently working on the last section to my assignment a.pdf
Hello. Im currently working on the last section to my assignment a.pdfHello. Im currently working on the last section to my assignment a.pdf
Hello. Im currently working on the last section to my assignment a.pdf
 
Create a class named Student that has the following member variables.pdf
Create a class named Student that has the following member variables.pdfCreate a class named Student that has the following member variables.pdf
Create a class named Student that has the following member variables.pdf
 
please help with java questionsJAVA CODEplease check my code and.pdf
please help with java questionsJAVA CODEplease check my code and.pdfplease help with java questionsJAVA CODEplease check my code and.pdf
please help with java questionsJAVA CODEplease check my code and.pdf
 
HELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdfHELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdf
 
Class 6 2ciclo
Class 6 2cicloClass 6 2ciclo
Class 6 2ciclo
 
Inheritance 3.pptx
Inheritance 3.pptxInheritance 3.pptx
Inheritance 3.pptx
 
C# programs
C# programsC# programs
C# programs
 
JavaExamples
JavaExamplesJavaExamples
JavaExamples
 
So Far I have these two classes but I need help with my persontest c.pdf
So Far I have these two classes but I need help with my persontest c.pdfSo Far I have these two classes but I need help with my persontest c.pdf
So Far I have these two classes but I need help with my persontest c.pdf
 
Algoritmos sujei
Algoritmos sujeiAlgoritmos sujei
Algoritmos sujei
 
operating system linux,ubuntu,Mac Geometri.pdf
operating system linux,ubuntu,Mac Geometri.pdfoperating system linux,ubuntu,Mac Geometri.pdf
operating system linux,ubuntu,Mac Geometri.pdf
 
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDBTDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
 
How to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy CodeHow to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy Code
 
BasicPizza.javapublic class BasicPizza { Declaring instance .pdf
BasicPizza.javapublic class BasicPizza { Declaring instance .pdfBasicPizza.javapublic class BasicPizza { Declaring instance .pdf
BasicPizza.javapublic class BasicPizza { Declaring instance .pdf
 
Kotlin Data Model
Kotlin Data ModelKotlin Data Model
Kotlin Data Model
 
Sam wd programs
Sam wd programsSam wd programs
Sam wd programs
 
Exercises of java tutoring -version1
Exercises of java tutoring -version1Exercises of java tutoring -version1
Exercises of java tutoring -version1
 
COW
COWCOW
COW
 
Listing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdfListing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdf
 

More from aplolomedicalstoremr

You have to leave solids and liquids out of the equation. This lea.pdf
You have to leave solids and liquids out of the equation. This lea.pdfYou have to leave solids and liquids out of the equation. This lea.pdf
You have to leave solids and liquids out of the equation. This lea.pdf
aplolomedicalstoremr
 
Tungsten is a body centered cubic latticeSolutionTungsten is a.pdf
Tungsten is a body centered cubic latticeSolutionTungsten is a.pdfTungsten is a body centered cubic latticeSolutionTungsten is a.pdf
Tungsten is a body centered cubic latticeSolutionTungsten is a.pdf
aplolomedicalstoremr
 
This is the final code which meets your requirement.Than youCard.j.pdf
This is the final code which meets your requirement.Than youCard.j.pdfThis is the final code which meets your requirement.Than youCard.j.pdf
This is the final code which meets your requirement.Than youCard.j.pdf
aplolomedicalstoremr
 
Statistics is the mathematical science involving the collection, ana.pdf
Statistics is the mathematical science involving the collection, ana.pdfStatistics is the mathematical science involving the collection, ana.pdf
Statistics is the mathematical science involving the collection, ana.pdf
aplolomedicalstoremr
 
Secondary phloemApples (Malus communis, M. pumila, & M. sylvestr.pdf
Secondary phloemApples (Malus communis, M. pumila, & M. sylvestr.pdfSecondary phloemApples (Malus communis, M. pumila, & M. sylvestr.pdf
Secondary phloemApples (Malus communis, M. pumila, & M. sylvestr.pdf
aplolomedicalstoremr
 
Polygon .java package chegg2;public class Polygon { Var.pdf
Polygon .java package chegg2;public class Polygon {  Var.pdfPolygon .java package chegg2;public class Polygon {  Var.pdf
Polygon .java package chegg2;public class Polygon { Var.pdf
aplolomedicalstoremr
 
probability that the trajectory falls between 1.2 and 1.4 =(1.4-1.2).pdf
probability that the trajectory falls between 1.2 and 1.4 =(1.4-1.2).pdfprobability that the trajectory falls between 1.2 and 1.4 =(1.4-1.2).pdf
probability that the trajectory falls between 1.2 and 1.4 =(1.4-1.2).pdf
aplolomedicalstoremr
 
OutputFibonacci till 20 0 1 1 2 3 5 8 13 21 .pdf
OutputFibonacci till 20 0 1 1 2 3 5 8 13 21 .pdfOutputFibonacci till 20 0 1 1 2 3 5 8 13 21 .pdf
OutputFibonacci till 20 0 1 1 2 3 5 8 13 21 .pdf
aplolomedicalstoremr
 
Matter is made up of electrically charge particle but the Constituen.pdf
Matter is made up of electrically charge particle but the Constituen.pdfMatter is made up of electrically charge particle but the Constituen.pdf
Matter is made up of electrically charge particle but the Constituen.pdf
aplolomedicalstoremr
 
it is a polynomial of degree 3Solutionit is a polynomial of de.pdf
it is a polynomial of degree 3Solutionit is a polynomial of de.pdfit is a polynomial of degree 3Solutionit is a polynomial of de.pdf
it is a polynomial of degree 3Solutionit is a polynomial of de.pdf
aplolomedicalstoremr
 
JUnit is a Regression Testing Framework used by developers to implem.pdf
JUnit is a Regression Testing Framework used by developers to implem.pdfJUnit is a Regression Testing Framework used by developers to implem.pdf
JUnit is a Regression Testing Framework used by developers to implem.pdf
aplolomedicalstoremr
 
Intitially take a graph sheet and plot the points and the whole figu.pdf
Intitially take a graph sheet and plot the points and the whole figu.pdfIntitially take a graph sheet and plot the points and the whole figu.pdf
Intitially take a graph sheet and plot the points and the whole figu.pdf
aplolomedicalstoremr
 
Incapsula Enterprise is the best mitigation service provider with th.pdf
Incapsula Enterprise is the best mitigation service provider with th.pdfIncapsula Enterprise is the best mitigation service provider with th.pdf
Incapsula Enterprise is the best mitigation service provider with th.pdf
aplolomedicalstoremr
 
Go with the most obvious one first...Carboxylic Acids will have a.pdf
Go with the most obvious one first...Carboxylic Acids will have a.pdfGo with the most obvious one first...Carboxylic Acids will have a.pdf
Go with the most obvious one first...Carboxylic Acids will have a.pdf
aplolomedicalstoremr
 
Flexible benefit plans gives employees a choice between qualified be.pdf
Flexible benefit plans gives employees a choice between qualified be.pdfFlexible benefit plans gives employees a choice between qualified be.pdf
Flexible benefit plans gives employees a choice between qualified be.pdf
aplolomedicalstoremr
 
f(x) = cos(x)Solutionf(x) = cos(x).pdf
f(x) = cos(x)Solutionf(x) = cos(x).pdff(x) = cos(x)Solutionf(x) = cos(x).pdf
f(x) = cos(x)Solutionf(x) = cos(x).pdf
aplolomedicalstoremr
 
EnvironmentLet assume the environment is a grid of colored tiles(.pdf
EnvironmentLet assume the environment is a grid of colored tiles(.pdfEnvironmentLet assume the environment is a grid of colored tiles(.pdf
EnvironmentLet assume the environment is a grid of colored tiles(.pdf
aplolomedicalstoremr
 
Classification of organisms is based upon a number of physical and p.pdf
Classification of organisms is based upon a number of physical and p.pdfClassification of organisms is based upon a number of physical and p.pdf
Classification of organisms is based upon a number of physical and p.pdf
aplolomedicalstoremr
 
Assets=Liabilities+Paid in capital+Retained earnings1..pdf
Assets=Liabilities+Paid in capital+Retained earnings1..pdfAssets=Liabilities+Paid in capital+Retained earnings1..pdf
Assets=Liabilities+Paid in capital+Retained earnings1..pdf
aplolomedicalstoremr
 
Hypothesis Test for population variance If we have a sample fro.pdf
 Hypothesis Test for population variance If we have a sample fro.pdf Hypothesis Test for population variance If we have a sample fro.pdf
Hypothesis Test for population variance If we have a sample fro.pdf
aplolomedicalstoremr
 

More from aplolomedicalstoremr (20)

You have to leave solids and liquids out of the equation. This lea.pdf
You have to leave solids and liquids out of the equation. This lea.pdfYou have to leave solids and liquids out of the equation. This lea.pdf
You have to leave solids and liquids out of the equation. This lea.pdf
 
Tungsten is a body centered cubic latticeSolutionTungsten is a.pdf
Tungsten is a body centered cubic latticeSolutionTungsten is a.pdfTungsten is a body centered cubic latticeSolutionTungsten is a.pdf
Tungsten is a body centered cubic latticeSolutionTungsten is a.pdf
 
This is the final code which meets your requirement.Than youCard.j.pdf
This is the final code which meets your requirement.Than youCard.j.pdfThis is the final code which meets your requirement.Than youCard.j.pdf
This is the final code which meets your requirement.Than youCard.j.pdf
 
Statistics is the mathematical science involving the collection, ana.pdf
Statistics is the mathematical science involving the collection, ana.pdfStatistics is the mathematical science involving the collection, ana.pdf
Statistics is the mathematical science involving the collection, ana.pdf
 
Secondary phloemApples (Malus communis, M. pumila, & M. sylvestr.pdf
Secondary phloemApples (Malus communis, M. pumila, & M. sylvestr.pdfSecondary phloemApples (Malus communis, M. pumila, & M. sylvestr.pdf
Secondary phloemApples (Malus communis, M. pumila, & M. sylvestr.pdf
 
Polygon .java package chegg2;public class Polygon { Var.pdf
Polygon .java package chegg2;public class Polygon {  Var.pdfPolygon .java package chegg2;public class Polygon {  Var.pdf
Polygon .java package chegg2;public class Polygon { Var.pdf
 
probability that the trajectory falls between 1.2 and 1.4 =(1.4-1.2).pdf
probability that the trajectory falls between 1.2 and 1.4 =(1.4-1.2).pdfprobability that the trajectory falls between 1.2 and 1.4 =(1.4-1.2).pdf
probability that the trajectory falls between 1.2 and 1.4 =(1.4-1.2).pdf
 
OutputFibonacci till 20 0 1 1 2 3 5 8 13 21 .pdf
OutputFibonacci till 20 0 1 1 2 3 5 8 13 21 .pdfOutputFibonacci till 20 0 1 1 2 3 5 8 13 21 .pdf
OutputFibonacci till 20 0 1 1 2 3 5 8 13 21 .pdf
 
Matter is made up of electrically charge particle but the Constituen.pdf
Matter is made up of electrically charge particle but the Constituen.pdfMatter is made up of electrically charge particle but the Constituen.pdf
Matter is made up of electrically charge particle but the Constituen.pdf
 
it is a polynomial of degree 3Solutionit is a polynomial of de.pdf
it is a polynomial of degree 3Solutionit is a polynomial of de.pdfit is a polynomial of degree 3Solutionit is a polynomial of de.pdf
it is a polynomial of degree 3Solutionit is a polynomial of de.pdf
 
JUnit is a Regression Testing Framework used by developers to implem.pdf
JUnit is a Regression Testing Framework used by developers to implem.pdfJUnit is a Regression Testing Framework used by developers to implem.pdf
JUnit is a Regression Testing Framework used by developers to implem.pdf
 
Intitially take a graph sheet and plot the points and the whole figu.pdf
Intitially take a graph sheet and plot the points and the whole figu.pdfIntitially take a graph sheet and plot the points and the whole figu.pdf
Intitially take a graph sheet and plot the points and the whole figu.pdf
 
Incapsula Enterprise is the best mitigation service provider with th.pdf
Incapsula Enterprise is the best mitigation service provider with th.pdfIncapsula Enterprise is the best mitigation service provider with th.pdf
Incapsula Enterprise is the best mitigation service provider with th.pdf
 
Go with the most obvious one first...Carboxylic Acids will have a.pdf
Go with the most obvious one first...Carboxylic Acids will have a.pdfGo with the most obvious one first...Carboxylic Acids will have a.pdf
Go with the most obvious one first...Carboxylic Acids will have a.pdf
 
Flexible benefit plans gives employees a choice between qualified be.pdf
Flexible benefit plans gives employees a choice between qualified be.pdfFlexible benefit plans gives employees a choice between qualified be.pdf
Flexible benefit plans gives employees a choice between qualified be.pdf
 
f(x) = cos(x)Solutionf(x) = cos(x).pdf
f(x) = cos(x)Solutionf(x) = cos(x).pdff(x) = cos(x)Solutionf(x) = cos(x).pdf
f(x) = cos(x)Solutionf(x) = cos(x).pdf
 
EnvironmentLet assume the environment is a grid of colored tiles(.pdf
EnvironmentLet assume the environment is a grid of colored tiles(.pdfEnvironmentLet assume the environment is a grid of colored tiles(.pdf
EnvironmentLet assume the environment is a grid of colored tiles(.pdf
 
Classification of organisms is based upon a number of physical and p.pdf
Classification of organisms is based upon a number of physical and p.pdfClassification of organisms is based upon a number of physical and p.pdf
Classification of organisms is based upon a number of physical and p.pdf
 
Assets=Liabilities+Paid in capital+Retained earnings1..pdf
Assets=Liabilities+Paid in capital+Retained earnings1..pdfAssets=Liabilities+Paid in capital+Retained earnings1..pdf
Assets=Liabilities+Paid in capital+Retained earnings1..pdf
 
Hypothesis Test for population variance If we have a sample fro.pdf
 Hypothesis Test for population variance If we have a sample fro.pdf Hypothesis Test for population variance If we have a sample fro.pdf
Hypothesis Test for population variance If we have a sample fro.pdf
 

Recently uploaded

"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 

Recently uploaded (20)

"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 

@author public class Person{   String sname, .pdf

  • 1. /** * @author * */ public class Person { String sname, iname; int fid, sid; } /** * @author * */ public class Student extends Person { String sname; int sid; int no_of_credits, tot_grade_pts; /** * @param sname * @param sid */ public Student(String sname, int sid) { this.sname = sname; this.sid = sid; } /** * @return */ public String get_name() { return sname; } public int get_sid()
  • 2. { return sid; } public boolean two_equal(int sid) { if ((this.sid) == sid) return true; else return false; } public void set_credits(int credits) { no_of_credits = credits; } public int get_credits() { return no_of_credits; } public void set_tot_gpts(int gpts) { tot_grade_pts = gpts; } public int get_tgpts() { return tot_grade_pts; } public float get_GPA() { return ((tot_grade_pts) / (no_of_credits)); } } /** * @author * */ public class Instructor extends Person
  • 3. { String iname; int fid; String dept; /** * @param iname * @param fid */ public Instructor(String iname, int fid) { this.iname = iname; this.fid = fid; } /** * @param dept */ void set_dept(String dept) { this.dept = dept; } /** * @return */ public String get_dept() { return dept; } } import java.util.ArrayList; /** * @author * */ public class Course { String cname, instructor_name;
  • 4. int creg_code, max_students, no_of_students; ArrayList reg_students = new ArrayList(); /** * @param cname * @param creg_code * @param max_students */ Course(String cname, int creg_code, int max_students) { this.cname = cname; this.creg_code = creg_code; this.max_students = max_students; } /** * @param instructor_name */ void set_instructor(String instructor_name) { this.instructor_name = instructor_name; } /** * method to search student id * * @param sid * @return */ public boolean search_student(int sid) { if (reg_students.contains(sid)) return true; else return false; } /** * method to add student id *
  • 5. * @param sid */ public void add_student(int sid) { try { if ((reg_students.size()) == max_students) { throw new MyException(); } else reg_students.add(sid); } catch (Exception e) { System.out.println("Course has maximum students"); } } /** * method to remove student id * * @param sid */ public void rem_student(int sid) { try { if (reg_students.contains(sid)) reg_students.remove(new Integer(sid)); else throw new MyException(); } catch (Exception e) { System.out.println("NO STUDENT FOUND WITH THE GIVEN id"); } } } /**
  • 6. * @author * */ public class MyException extends Exception { public MyException() { // TODO Auto-generated constructor stub super(" Invalid Data"); } } import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Registrar { /** * @param args * @throws NumberFormatException * @throws IOException */ public static void main(String args[]) throws NumberFormatException, IOException { Course c1 = new Course("default_course", 123, 10); int ch, regcode, max_stu, sid; String cname, sname; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); do { System.out .println(" 1. create a course 2. add a student 3. remove a student 4. exit"); System.out.print("Enter your choice: "); ch = Integer.parseInt(br.readLine()); switch (ch) { case 1: System.out.print("Enter course name:");
  • 7. cname = br.readLine(); System.out.print("Eter registration code :"); regcode = Integer.parseInt(br.readLine()); System.out.print("Enter max students :"); max_stu = Integer.parseInt(br.readLine()); Course c = new Course(cname, regcode, max_stu); break; case 2: System.out.print("Enter student name: "); sname = br.readLine(); System.out.print("Enter id : "); sid = Integer.parseInt(br.readLine()); c1.add_student(sid); break; case 3: System.out.print("Enter student id: "); sid = Integer.parseInt(br.readLine()); c1.rem_student(sid); break; } } while (ch != 4); } } OUTPUT: 1. create a course 2. add a student 3. remove a student 4. exit Enter your choice: 1 Enter course name:computers Eter registration code :1211 Enter max students :30 1. create a course 2. add a student 3. remove a student 4. exit
  • 8. Enter your choice: 2 Enter student name: srinivas Enter id : 1 1. create a course 2. add a student 3. remove a student 4. exit Enter your choice: 2 Enter student name: rajesh Enter id : 2 1. create a course 2. add a student 3. remove a student 4. exit Enter your choice: 3 Enter student id: 1 1. create a course 2. add a student 3. remove a student 4. exit Enter your choice: 4 NOTE: DONT HAVE TIME TO IMPLEMENT SERIALIZATION THINGS Solution /** * @author * */ public class Person { String sname, iname; int fid, sid; } /**
  • 9. * @author * */ public class Student extends Person { String sname; int sid; int no_of_credits, tot_grade_pts; /** * @param sname * @param sid */ public Student(String sname, int sid) { this.sname = sname; this.sid = sid; } /** * @return */ public String get_name() { return sname; } public int get_sid() { return sid; } public boolean two_equal(int sid) { if ((this.sid) == sid) return true; else return false; } public void set_credits(int credits)
  • 10. { no_of_credits = credits; } public int get_credits() { return no_of_credits; } public void set_tot_gpts(int gpts) { tot_grade_pts = gpts; } public int get_tgpts() { return tot_grade_pts; } public float get_GPA() { return ((tot_grade_pts) / (no_of_credits)); } } /** * @author * */ public class Instructor extends Person { String iname; int fid; String dept; /** * @param iname * @param fid */ public Instructor(String iname, int fid) { this.iname = iname;
  • 11. this.fid = fid; } /** * @param dept */ void set_dept(String dept) { this.dept = dept; } /** * @return */ public String get_dept() { return dept; } } import java.util.ArrayList; /** * @author * */ public class Course { String cname, instructor_name; int creg_code, max_students, no_of_students; ArrayList reg_students = new ArrayList(); /** * @param cname * @param creg_code * @param max_students */ Course(String cname, int creg_code, int max_students) { this.cname = cname; this.creg_code = creg_code;
  • 12. this.max_students = max_students; } /** * @param instructor_name */ void set_instructor(String instructor_name) { this.instructor_name = instructor_name; } /** * method to search student id * * @param sid * @return */ public boolean search_student(int sid) { if (reg_students.contains(sid)) return true; else return false; } /** * method to add student id * * @param sid */ public void add_student(int sid) { try { if ((reg_students.size()) == max_students) { throw new MyException(); } else reg_students.add(sid);
  • 13. } catch (Exception e) { System.out.println("Course has maximum students"); } } /** * method to remove student id * * @param sid */ public void rem_student(int sid) { try { if (reg_students.contains(sid)) reg_students.remove(new Integer(sid)); else throw new MyException(); } catch (Exception e) { System.out.println("NO STUDENT FOUND WITH THE GIVEN id"); } } } /** * @author * */ public class MyException extends Exception { public MyException() { // TODO Auto-generated constructor stub super(" Invalid Data"); } } import java.io.BufferedReader;
  • 14. import java.io.IOException; import java.io.InputStreamReader; public class Registrar { /** * @param args * @throws NumberFormatException * @throws IOException */ public static void main(String args[]) throws NumberFormatException, IOException { Course c1 = new Course("default_course", 123, 10); int ch, regcode, max_stu, sid; String cname, sname; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); do { System.out .println(" 1. create a course 2. add a student 3. remove a student 4. exit"); System.out.print("Enter your choice: "); ch = Integer.parseInt(br.readLine()); switch (ch) { case 1: System.out.print("Enter course name:"); cname = br.readLine(); System.out.print("Eter registration code :"); regcode = Integer.parseInt(br.readLine()); System.out.print("Enter max students :"); max_stu = Integer.parseInt(br.readLine()); Course c = new Course(cname, regcode, max_stu); break; case 2: System.out.print("Enter student name: "); sname = br.readLine(); System.out.print("Enter id : ");
  • 15. sid = Integer.parseInt(br.readLine()); c1.add_student(sid); break; case 3: System.out.print("Enter student id: "); sid = Integer.parseInt(br.readLine()); c1.rem_student(sid); break; } } while (ch != 4); } } OUTPUT: 1. create a course 2. add a student 3. remove a student 4. exit Enter your choice: 1 Enter course name:computers Eter registration code :1211 Enter max students :30 1. create a course 2. add a student 3. remove a student 4. exit Enter your choice: 2 Enter student name: srinivas Enter id : 1 1. create a course 2. add a student 3. remove a student 4. exit Enter your choice: 2 Enter student name: rajesh Enter id : 2 1. create a course
  • 16. 2. add a student 3. remove a student 4. exit Enter your choice: 3 Enter student id: 1 1. create a course 2. add a student 3. remove a student 4. exit Enter your choice: 4 NOTE: DONT HAVE TIME TO IMPLEMENT SERIALIZATION THINGS