• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Simple Enrollment System

 
Greenhorn
Posts: 10
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys, I need help in making enrollment system that would use inheritance and overload and the output should be:

Ex. Screen Output
Menu
[1]Enter Subjects
[2]Enter Students
[3]Enter Teachers
[4] Exit - Displacy Output from choices
choice:1
Enter Subject code: ITEP111
Enter Subject Desc: Intro to Programming
Enter Subject Sched: M TH 5-9
Enter Subject Units: 5

Menu
[1]Enter Subjects
[2]Enter Students
[3]Enter Teachers
[4] Exit - Displacy Output from choices

choice:2
Enter Student ID: 123
Enter Student name:Chris
Enter Student Address:Davao City
Enter Student Course:BSIT

Enter How many Subjects: 3
Enter subjCode:ITEP111
Enter subjCode:ITEP211
Enter subjCode:ITEP113


Menu
[1]Enter Subjects
[2]Enter Students
[3]Enter Teachers
[4] Exit - Displacy Output from choices

choice:3
Enter Teacher ID: 1
Enter Teacher Name: Joting
Enter Teacher Dept: IT

1]Enter Subjects
[2]Enter Students
[3]Enter Teachers
[4] Exit - Display Output from choices

choice:4

Records --

Students
ID:123
Name: Chris
Address: Davao City
Course: BSIT

SubjCode: ITEP111
SubjDesc: Intro to PRog

SubjCode: ITEP211
SubjDesc: Intro to OOP

SubjCode: ITEP113
SubjDesc: Intro to WEB Page

Teachers
Teacher ID:125
Teacher Name: Juan
Teacher Dept: ICT

I attached here the sample code and my code for enrollment system without inheritance and and overloading.
 
Marshal
Posts: 79153
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

I couldn't see any attached code. Please explain how far you have got, and what problems you are experiencing.
 
Jaylie Beam Galang
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Marchal! Sorry, I forgot to attach the file. Here's my code for the basic enrollment system during our midterms, now my professor wants to apply the inheritance and overloading from His example "payroll system" with dependents here: https://justpaste.it/1elq  And I really don't know how to start it.

 
Jaylie Beam Galang
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sample output:

Display Menu
[1]Enter Subjects
[2]Enter Students
[3]Enter Teachers
[4]Display All Data
[5]Exit

Choice:1
Enter Subject code: ITEP111
Enter Subject Desc: Intro to Programming
Enter Subject Sched: M TH 5-9
Enter Subject Units: 5

Display Menu
[1]Enter Subjects
[2]Enter Students
[3]Enter Teachers
[4]Display All Data
[5]Exit

Choice:2
Enter Student ID: 123
Enter Student name:Chris
Enter Student Address:Davao City
Enter Student Course:BSIT

(Dependence of Student class)
Enter How many Subjects: 3
Enter subjCode:ITEP111
Enter subjCode:ITEP211
Enter subjCode:ITEP113


Display Menu
[1]Enter Subjects
[2]Enter Students
[3]Enter Teachers
[4]Display All Data
[5]Exit

Choice:3
Enter Teacher ID: 1
Enter Teacher Name: Joting
Enter Teacher Dept: IT

Display Menu
[1]Enter Subjects
[2]Enter Students
[3]Enter Teachers
[4]Display All Data
[5]Exit

Choice:4

Records --

Subjects:
Code: ITEP111
Desc: Intro to Programming
Sched: M TH 5-9
Units: 5

Students:
ID:123
Name: Chris
Address: Davao City
Course: BSIT

SubjCode: ITEP111
SubjDesc: Intro to PRog
SubjCode: ITEP211
SubjDesc: Intro to OOP
SubjCode: ITEP113
SubjDesc: Intro to WEB Page

Teachers:
Teacher ID:125
Teacher Name: Juan
Teacher Dept: ICT

 
Jaylie Beam Galang
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The most struggle part is how to display all entered  information completely at last when the user chose [Display all data]
 
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you know about Lists or arrays?  Hopefully you can use List to keep track of all the objects that are entered.  Arrays have the disadvantage that you have to know how big they can get when you create them.

You have everything in the main() method.  See MainIsAPain (that's a link).
 
Jaylie Beam Galang
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Knute, I used Arraylist here's my updated code. I just lack a piece of code that will fetch the subject description in the array if I entered a specific subject code in the Students dependents.

================
Enter How many Subjects: 3
Enter subjCode:ITEP111
Enter subjCode:ITEP211
Enter subjCode:ITEP113

display:

SubjCode: ITEP111
SubjDesc: Intro to PRog

SubjCode: ITEP211
SubjDesc: Intro to OOP

SubjCode: ITEP113
SubjDesc: Intro to WEB Page









 
Jaylie Beam Galang
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please help guys
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jaylie Beam Galang wrote:Please help guys



You posted several hundred lines of code but you didn't ask a question about it. What kind of help were you looking for?
 
Knute Snortum
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I just lack a piece of code that will fetch the subject description in the array if I entered a specific subject code in the Students dependents.  


It seems like you fetch the description fine from the code.  What problems are you having?  TellTheDetails (that's a link).
 
Knute Snortum
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jaylie Beam Galang wrote:Please help guys


PatienceIsAVirtue (that's a link).
 
Jaylie Beam Galang
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys, Sorry for not being clear earlier. Thanks Knute for the tips!

Here's my goal--
Step 1 - User input subjects (code, description, sched, units)
Step 2 - User inputs Students info with the dependents on how may subject the user should enroll(the program should ask the given subject code to call from the Step 1, if the code found in the list of Subjects it should print the Subject code together with the Subject description. If the code is not found should print "No code found in the Subject list")
Step 3 - User inputs teachers info
Step 4 - Display all info


The following is my sample output, the problem is I'm getting "NULL" in the Student's dependent -- subject description

Enrollment System
++++++++++++++++++
[1] Enter Subjects
[2] Enter Students
[3] Enter Teachers
[4] Display all records
[5] Exit
Enter choice:
1

[Subject Info]
Enter Subject Code:123
Enter Subject Description: Prog1
Enter Subject Schedule: MWF
Enter Subject Units: 3

Enrollment System
++++++++++++++++++
[1] Enter Subjects
[2] Enter Students
[3] Enter Teachers
[4] Display all records
[5] Exit
Enter choice:
2

[Student Info]
Enter Student ID:12M
Enter Student Name: Guia
Enter Student Address: SIR
Enter Student Course:BSIT
How many subjects?:
1
[1]Enter Subject code:
123

Enrollment System
++++++++++++++++++
[1] Enter Subjects
[2] Enter Students
[3] Enter Teachers
[4] Display all records
[5] Exit
Enter choice:
3

[Teacher Info]
Enter Teacher ID:12teach
Enter Teacher Name: tony
Enter Teacher Department:bsit

Enrollment System
++++++++++++++++++
[1] Enter Subjects
[2] Enter Students
[3] Enter Teachers
[4] Display all records
[5] Exit
Enter choice:
4

SUBJECT
Code:123
Description:Prog1
Schedule: MWF
Units:3

STUDENT
ID:12M
Name:Guia
Address: SIR
Course:BSIT

Subject Code: 123
Subject Description: null

TEACHER
ID:12teach
Name:tony
Department: bsit

Here's the dependents code

 
Rancher
Posts: 4801
50
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

So the above reads in the code (123 in your example).
It then creates a new Subject instance and, I'm not sure what.
But the Subject created seems to have no relationship to the entered code.

I would expect some search to be done on a list of Subjects to find the one with the matching code.
 
Jaylie Beam Galang
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Dave! Can you give a sample code to search a list based on my code above?
 
Jaylie Beam Galang
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Subjects is in a separate class --



 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where do you store all your Subjects?
(Note, that class ought to be called Subject as it seems to only be dealing with a single Subject).
 
Jaylie Beam Galang
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I store my subjects within the subjects class file
 
Knute Snortum
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your Students class has some very basic problems in it.

* Why does Students extend Subjects?  Is a Students a specialize Subjects?
* You have a method getStudInfo(String code, String desc) that doesn't return anything.  Usually a getXxx() method returns xxx.
* In getStudInfo(String code, String desc), you pass in code and desc, but you never use the passed in values.
* You get numdeps as the maximum number of subjects and you use it to limit a for loop, but then you use it as if it's an index: e[numdeps]
* You have a for loop where i is never used.
* Get get a subject code, but never set it into a Subjects object.
* You set e[numdeps] = new Subjects(); which just sets it to an empty object.
* You call e[numdeps].getCode(); but a) no code has been set and b) you don't capture the return value (but do you need to?)
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jaylie Beam Galang wrote:I store my subjects within the subjects class file



Your Subjects class only holds data for a single Subject.

Which is fine in itself, but you would then need somewhere to store all the subjects.

Now, looking at your Menu class above, that has an array for holding Subjects.
So when you add a Student and assign a Subject based on its id, you need to search that array.

And at this point that might show a problem with the area of responsibility for each of your classes.
I think you would do better to have the data input code in the Menu class (at least for now), making the Subject/Student?teacher classes much simpler.
Then, when you prompt for the Subject id you can then search in the Subject[] easily for the matching object.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Welcome to the Ranch

can you show the flow of this prog??

 
Knute Snortum
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch!

I'm not sure I know what you mean by "show me the flow" of a program.  Can you elaborate?
 
Campbell Ritchie
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Knute Snortum wrote:. . . I'm not sure I know what you mean by "show me the flow" . . .

That appears in quote tags, but I appear not to have said it.

The original poster (=OP) appears not to have posted anything this year, so you will probably not get a reply from them. Maybe you would get useful information if you write a print instruction in every method, saying which code is being executed.

And . . . welcome to the Ranch
reply
    Bookmark Topic Watch Topic
  • New Topic