Question

You are required to create an application to store list of students and list of lecturers....

You are required to create an application to store list of students and list of lecturers. Following information are to be stored for each student:

- stdId: The student ID

- stdName: Student name

- stdDoB: Student date of birth

- stdEmail: Student email

- stdAddress: Student address

- stdBatch: The batch (class) of the student

Following information are to be stored for each lecturer:

- lecId: Lecturer ID with 8 digits (fixed)

- lecName: Lecturer

- lecDoB: Lecturer date of birth

- lecEmail: Lecturer email

- lecAddress: Lecturer address

- lecDept: Lecturer department (e.g., Computing, Business, etc)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Scanner;

// Defines a class to store student information

class OurStudent

{

// Instance variables to student information

String stdId;

String stdName;

String stdDoB;

String stdEmail;

String stdAddress;

String stdBatch;

// Default constructor to assign default values to

// instance variables

OurStudent()

{

stdId = stdName = stdDoB = stdEmail = stdAddress = stdBatch = "";

}// End of default constructor

// Method to accept student data

void accept()

{

// Scanner class object created

Scanner sc = new Scanner(System.in);

// Accepts student data

System.out.print("\n Enter Student information \n");

System.out.print("\n Enter ID: ");

stdId = sc.next();

System.out.print("\n Enter Name: ");

stdName = sc.next();

System.out.print("\n Enter DOB(d/m/y): ");

stdDoB = sc.next();

System.out.print("\n Enter Email: ");

stdEmail = sc.next();

// To skip newline character

sc.nextLine();

System.out.print("\n Enter Address: ");

stdAddress = sc.nextLine();

System.out.print("\n Enter Batch: ");

stdBatch = sc.next();

}// End of method

// Overrides toString() method to display

// student information

public String toString()

{

// Concatenates data and returns it

return "\n\n ID: " + stdId + "\n Name: " + stdName +

"\n DOB: " + stdDoB + "\n Email: " + stdEmail +

"\n Address: " + stdAddress +

"\n Batch: " + stdBatch;

}// End of method

}// End of class Student

// Defines a class to store lecturer information

class Lecturer

{

// Instance variables to lecturer information

String lecId;

String lecName;

String lecDoB;

String lecEmail;

String lecAddress;

String lecDept;

// Default constructor to assign default values to

// instance variables

Lecturer()

{

lecId = lecName = lecDoB = lecEmail = lecAddress = lecDept = "";

}// End of default constructor

// Method to accept lecturer data

void accept()

{

// Scanner class object created

Scanner sc = new Scanner(System.in);

System.out.print("\n Enter Lecturer information \n");

// Loops till id is not equals to 8 digits

do

{

// Accepts a id

System.out.print("\n Enter ID(8 digit): ");

lecId = sc.next();

// Checks if number of digits is greater than 8

// Displays error message

if(lecId.length() > 8)

System.out.print("\n Exceeds 8 digit. Try again!");

// Otherwise checks if number of digits is less than 8

// Displays error message

else if(lecId.length() < 8)

System.out.print("\n Below 8 digit. Try again!");

// Otherwise valid id come out of the loop

else

break;

}while(true);// End of do - while loop

// Accepts other data

System.out.print("\n Enter Name: ");

lecName = sc.next();

System.out.print("\n Enter DOB(d/m/y): ");

lecDoB = sc.next();

System.out.print("\n Enter Email: ");

lecEmail = sc.next();

sc.nextLine();

System.out.print("\n Enter Address: ");

lecAddress = sc.nextLine();

System.out.print("\n Enter Department: ");

lecDept = sc.next();

}// End of method

// Overrides toString() method to display

// lecturer information

public String toString()

{

// Concatenates data and returns it

return "\n\n ID: " + lecId + "\n Name: " + lecName +

"\n DOB: " + lecDoB + "\n Email: " + lecEmail +

"\n Address: " + lecAddress +

"\n Department: " + lecDept;

}// End of method

}// End of class Lecturer

// Driver class StudentLecturer definition

public class StudentLecturer

{

// main method definition

public static void main(String ss[])

{

// Scanner class object created

Scanner sc = new Scanner(System.in);

// Accept number of students

System.out.print("\n Enter number of Students information " +

"you want to add: ");

int no = sc.nextInt();

// Creates an array of objects of size no for students

OurStudent st[] = new OurStudent[no];

// Loops no times to accept student data

for(int c = 0; c < no; c++)

{

// Creates current object

st[c] = new OurStudent();

// Accept data for current object

st[c].accept();

}// End of for loop

System.out.print("\n *************** Student Information *************** ");

// Loops no number of times to displays student information

for(int c = 0; c < no; c++)

System.out.print(st[c]);

// Accept number of lecturers

System.out.print("\n Enter number of Lecturer information " +

"you want to add: ");

no = sc.nextInt();

// Creates an array of objects of size no for lecturer

Lecturer le[] = new Lecturer[no];

// Loops no times to accept student data

for(int c = 0; c < no; c++)

{

// Creates current object

le[c] = new Lecturer();

// Accept data for current object

le[c].accept();

}// End of for loop

System.out.print("\n *************** Lecturer Information *************** ");

// Loops no number of times to displays lecturer information

for(int c = 0; c < no; c++)

System.out.print(le[c]);

}// End of main method

}// End of class

Sample Output:


Enter number of Students information you want to add: 2

Enter Student information

Enter ID: 122231

Enter Name: Mohan

Enter DOB(d/m/y): 12/3/2004

Enter Email:
mohan@abc.com

Enter Address: Berhampur

Enter Batch: MCA

Enter Student information

Enter ID: 325689

Enter Name: Ram

Enter DOB(d/m/y): 5/2/2001

Enter Email: ram@abc.com

Enter Address: Cuttack, orissa.

Enter Batch: B.Tech

*************** Lecturer Information ***************  

ID: 122231
Name: Mohan
DOB: 12/3/2004
Email: mohan@abc.com
Address: Berhampur
Batch: MCA

ID: 325689
Name: Ram
DOB: 5/2/2001
Email: ram@abc.com
Address: Cuttack, orissa.
Batch: B.Tech
Enter number of Lecturer information you want to add: 1

Enter Lecturer information

Enter ID(8 digit): 122356

Below 8 digit. Try again!
Enter ID(8 digit): 1223568798

Exceeds 8 digit. Try again!
Enter ID(8 digit): 12236784

Enter Name: Suresh

Enter DOB(d/m/y): 12/3/2001

Enter Email: Suresh@abc.com

Enter Address: Banga, Bihar

Enter Department: Manager

*************** Student Information ***************  

ID: 12236784
Name: Suresh
DOB: 12/3/2001
Email: Suresh@abc.com
Address: Banga, Bihar
Department: Manager

Add a comment
Know the answer?
Add Answer to:
You are required to create an application to store list of students and list of lecturers....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 3. Suppose the University has two types of academics: students and lecturers. Both of these have...

    3. Suppose the University has two types of academics: students and lecturers. Both of these have names and ids, but students attend lectures while lecturers give them. class Student private: string name; string id; public: Student (string name, string id); string getName ); string getIDO; void attendLecture(); class Lecturer private: string name; string id; public: Lecturer(string name, string id); string getName; string getIDO; void giveLecture (); a) Write the header for a class called Academic and update the Student and...

  • Use C++ to create a class called Student, which represents the students of a university. A...

    Use C++ to create a class called Student, which represents the students of a university. A student is defined with the following attributes: id number (int), first name (string), last name (string), date of birth (string), address (string). and telephone (area code (int) and 7-digit telephone number(string). The member functions of the class Student must perform the following operations: Return the id numb Return the first name of the student Modify the first name of the student. . Return the...

  • Create Datasets for the ABC University Accommodation Office using the information below.This is a list of...

    Create Datasets for the ABC University Accommodation Office using the information below.This is a list of all the datasets and data attributes that the Office needs to function. For example, a STUDENT dataset containing StudentIDNumber, StudentFirstName, etc Scenario - ABC University Accommodation Office (Student Housing) The director of the ABC University Accommodation Office requires you to design a database to assist with the administration of the office and the renting of residences to students. The requirements collection and analysis phase...

  • Project 2 (required). Student Information Management System Write a GUI Application that is a MIS...

    i need help with the code and output screen shot Project 2 (required). Student Information Management System Write a GUI Application that is a MIS for students. Information of student includes student ID, name, date of birth, gender, major, grade, introduction, etc. The MIS has to provide insertion, deletion, query, and modification for students. To solve this application you have to: i. Design a friendly GUI based on JavaFX i. Provide the necessary functions, such as data insertion, data deletion,...

  • QUESTION Create the required java classes to store the students (id, name), the courses (id, title),...

    QUESTION Create the required java classes to store the students (id, name), the courses (id, title), the exam type (id, name) and the marks for each student. ► Add the necessary methods to; • Store the marks (%) for each student in the course. Search for a course, calculate the averages and display the course details as shown in the example below. Class: Computer Engineering Course Id:222 Course title: DataStructure Student Id Student Name Mid-Term Quiz (10%) Homework (10%) Project...

  • You have been approached by a University for the design and implementation of a relational databa...

    You have been approached by a University for the design and implementation of a relational database system that will provide information on the courses it offers, the academic departments that run the courses, the academic staff and the enrolled students. The system will be used mainly by the students and the academic staff. The requirement collection and analysis phase of the database design process provided the following data requirements for the University Database system. Using the following requirements answer this...

  • You will create an Microsoft Access School Management System Database that can be used to store,...

    You will create an Microsoft Access School Management System Database that can be used to store, retrieve update and delete the staff/student. Design an Access database to maintain information about school staff and students satisfying the following properties: 1. The staff should have the following: ID#, name, and classes they are teaching 2. The student should have the following: ID#, name, section, class 3. Create a module containing the section, subject and teacher information 4. Create a module containing student...

  • Help with database creation - create a visio ER diagram of the scenerio below.. thanks The...

    Help with database creation - create a visio ER diagram of the scenerio below.. thanks The registrar's office at Weber State University wants you to create a new database to support an future application that will help their department better keep track of the scheduled classes offered each semester, including the specific course sections and lecturers appearing in the schedule, and the students registering for courses according to the published schedule. Courses (think course catalog) may or may not be...

  • You are asked to build and test the following system using Java and the object-oriented concepts ...

    You are asked to build and test the following system using Java and the object-oriented concepts you learned in this course: Project (20 marks) CIT College of Information technology has students, faculty, courses and departments. You are asked to create a program to manage all these information's. Create a class CIT to represents the following: Array of Students, each student is represented by class Student. Array of Faculty, each faculty is represented by class Faculty. Array of Course, each course...

  • The application should be in JAVA and allow: 1. Collect student information and store it in...

    The application should be in JAVA and allow: 1. Collect student information and store it in a binary data file. Each student is identified by an unique ID. The user should be able to view/edit an existing student. Do not allow the user to edit student ID. 2. Collect Course information and store it in a separate data file. Each course is identified by an unique ID. The user should be able to view/edit an existing course information. User is...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT