943,845 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 503
  • Java RSS
Dec 9th, 2008
0

java help

Expand Post »
Student database creating a program that will be used to manipulate a student database. This portion of the database will keep track of student data to include the students name(first, middle, last), date-of-birth, the student's id number, the student's major, and the student's GPA.Based arrays and objects,use 2 parallel arrays of references that point to the objects. The first array will be an array of references pointing to Student objects. Each object will contain the students' name (first, middle, last), id number, major, and GPA. Each element in the array will point (be a reference) to a different Student object. need to create a Student class that contains a student's first, middle, and last name, a student id number, major, and GPA (these will be the data members). This class should have 2 constructors, accessors for each data member, a single mutator member to reset the student data (name,id number, major, and GPA). class should also have a toString() method to print out the data as well as an equals method to compare two student names for equality.
A second parallel array should be an array of references to Date objects that will house the birthdates for each student member. (i already written the Date class
java Syntax (Toggle Plain Text)
  1. public class Date
  2. {
  3.  
  4. private int month;
  5. private int day;
  6. private int year;
  7.  
  8. //-------constructor--------------------------------
  9. public Date()
  10. {
  11.  
  12. month = 01;
  13. day = 01;
  14. year = 01;
  15. }
  16. public Date(int mt,int ds,int yr)
  17. {
  18. //setDate(mt, ds, yr);
  19. month = mt;
  20. day = ds;
  21. year = yr;
  22.  
  23. }
  24.  
  25. //--------------mutator--------------------------
  26. public void setDate(int mt, int ds,int yr)
  27. {
  28. if (1 <= yr)
  29. year = yr;
  30. else
  31. yr = 1;
  32.  
  33. if (1 <= mt && mt <= 12)
  34. month = mt;
  35. else if (0 < mt && mt >12)
  36. System.out.println(" The month " + mt + " is invalid");
  37.  
  38.  
  39. if (1 <= ds && ds <= 31)
  40. day = ds;
  41. else if (0 < ds && ds > 31)
  42. System.out.println(" The day " + ds + " is invalid");
  43. else if (0 < ds && ds > 29)
  44. System.out.println(" The day for Febuary " + ds + " is invalid");
  45. }
  46.  
  47. //---------------accesor-----------------------------
  48. public int getYears()
  49. {
  50. return year;
  51. }
  52. public int getMonths()
  53. {
  54. return month;
  55. }
  56. public int getDays()
  57. {
  58. return day;
  59. }
  60.  
  61. //---------------------------------------------
  62. public boolean checkDate()
  63. {
  64. switch (month)
  65. {
  66. case 4: case 6: case 9: case 11:
  67. if (day <= 30)
  68. return true;
  69.  
  70. break;
  71.  
  72. case 1: case 3: case 5: case 7: case 8: case 10:case 12:
  73.  
  74. if(day <= 31)
  75. return true;
  76. break;
  77.  
  78. case 2:
  79. if (day <= 28 && !isLeapYear(year))
  80. return true;
  81. else if (day <= 29 && isLeapYear(year))
  82. return true;
  83.  
  84. break;
  85.  
  86. }
  87. return false;
  88. }
  89. public boolean isLeapYear(int years)
  90. {
  91. boolean isLeap = false;
  92.  
  93. if(((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
  94. {
  95. System.out.print(year + " is a leap year");
  96. isLeap = true;
  97. }
  98.  
  99. else
  100. System.out.println(year + " is not a leap year");
  101. System.out.flush();
  102.  
  103. return isLeap;
  104. }
  105.  
  106. public void makeCopy(Date otherDate)
  107. {
  108. month = otherDate.month;
  109. day = otherDate.day;
  110. year = otherDate.year;
  111. }
  112.  
  113.  
  114. public Date getCopy()
  115. {
  116. Date temp = new Date();
  117.  
  118. temp.month = month;
  119. temp.day = day;
  120. temp.year = year;
  121.  
  122. return temp;
  123. }
  124. public void printDate()
  125. {
  126. System.out.println(month + "/" + day + "/" + year);
  127. }
  128. }


Since these are parallel arrays, the data for student[i] in the student array will correspond
with birthdate[i] in the birthday array. Both of the parallel arrays will be located in driver (main) program. The Student Class and the Date class will be located in the same folder along with driver program, so that driver program can access these classes and their
methods as needed.

What program should do (Tasks):

i) Read data in from an external file that
ii) Print (to the screen) all the data for any given student (including the birthdate)
in an easy readable format.
ii) Your program should prompt the user for the name of a student, search through the list, and be able to print out the data for that student.
ii) Your program should prompt the user for a month (as an integer) be able to print out a list of all students who have birthdays in that month and wish them a Happy Birthday.

Structure of Program:
In a single folder should have a Date Class file, a Student Class file, the infile, and the main driver program.
The driver program (main) will contain the 2 parallel arrays.

outfile:
Doc David Dwarf 007 ComputerScience 4.0 01 01 1980
Grumpy Nat Gannon 120 Engineering 3.8 11 11 1989
Happy Jose Carreras 008 PreMed 3.5 03 04 1985
Sleepy Sam Smith 101 English 3.0 06 15 1887
Dopey Dan Doughnut 009 PoliticalScience 2.5 02 02 1887
Sneezy Salvadore Smith 198 Nursing 2.4 06 12 1990
Bashful Bob O'Brennan 101 ComputerScience 2.8 11 20 1888
Last edited by Ancient Dragon; Dec 9th, 2008 at 2:34 am. Reason: add code tags
Reputation Points: 10
Solved Threads: 0
Newbie Poster
star100 is offline Offline
5 posts
since Dec 2008
Dec 9th, 2008
0

Re: java help

And your question is?
Reputation Points: 33
Solved Threads: 18
Junior Poster in Training
mahlerfive is offline Offline
77 posts
since Aug 2008
Dec 9th, 2008
0

Re: java help

same remark here... and.. yet another (two)
why don't you use the (already existing) Date class? (java.util.Date)
if you do want to write your own, wouldn't it be better to give it another name, to avoid confusion? something like 'MyDate.java'
Reputation Points: 935
Solved Threads: 356
Nearly a Posting Maven
stultuske is offline Offline
2,497 posts
since Jan 2007
Dec 9th, 2008
0

Re: java help

how can i code for student data base using this information?
What program should do (Tasks):

i) Read data in from an external file that
ii) Print (to the screen) all the data for any given student (including the birthdate)
in an easy readable format.
ii) Your program should prompt the user for the name of a student, search through the list, and be able to print out the data for that student.
ii) Your program should prompt the user for a month (as an integer) be able to print out a list of all students who have birthdays in that month and wish them a Happy Birthday.

Structure of Program:
In a single folder should have a Date Class file, a Student Class file, the infile, and the main driver program.
The driver program (main) will contain the 2 parallel arrays.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
star100 is offline Offline
5 posts
since Dec 2008
Dec 9th, 2008
0

Re: java help

Click to Expand / Collapse  Quote originally posted by mahlerfive ...
And your question is?
Click to Expand / Collapse  Quote originally posted by star100 ...
how can i code for student data base using this information?
I don't think that's what mahlerfive meant when he asked what your question was. You simply reposted the assignment, then asked how to code it. You need to make an attempt and then ask a more SPECIFIC question regarding some aspect of the assignment, and it needs to show some effort on your part.
Featured Poster
Reputation Points: 2614
Solved Threads: 687
Posting Expert
VernonDozier is offline Offline
5,375 posts
since Jan 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: JAVA coding help
Next Thread in Java Forum Timeline: Passing by "reference" - how to change primitive type in a function





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC