SlideShare a Scribd company logo
1 of 16
Download to read offline
/**
* @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.pdfforwardcom41
 
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.pdfirshadkumar3
 
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.pdfarrowvisionoptics
 
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.pdfarishmarketing21
 
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.pdffatoryoutlets
 
Inheritance 3.pptx
Inheritance 3.pptxInheritance 3.pptx
Inheritance 3.pptxSamanAshraf9
 
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.pdfarihantgiftgallery
 
Algoritmos sujei
Algoritmos sujeiAlgoritmos sujei
Algoritmos sujeigersonjack
 
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.pdfaquadreammail
 
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 RavenDBtdc-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 CodeDaniel 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 .pdfankitmobileshop235
 
Kotlin Data Model
Kotlin Data ModelKotlin Data Model
Kotlin Data ModelKros 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 {   .pdfAnkitchhabra28
 

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.pdfaplolomedicalstoremr
 
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.pdfaplolomedicalstoremr
 
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.pdfaplolomedicalstoremr
 
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.pdfaplolomedicalstoremr
 
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.pdfaplolomedicalstoremr
 
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.pdfaplolomedicalstoremr
 
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).pdfaplolomedicalstoremr
 
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 .pdfaplolomedicalstoremr
 
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.pdfaplolomedicalstoremr
 
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.pdfaplolomedicalstoremr
 
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.pdfaplolomedicalstoremr
 
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.pdfaplolomedicalstoremr
 
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.pdfaplolomedicalstoremr
 
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.pdfaplolomedicalstoremr
 
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.pdfaplolomedicalstoremr
 
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).pdfaplolomedicalstoremr
 
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(.pdfaplolomedicalstoremr
 
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.pdfaplolomedicalstoremr
 
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..pdfaplolomedicalstoremr
 
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.pdfaplolomedicalstoremr
 

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

Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 

Recently uploaded (20)

Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 

@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