aspose file tools*
The moose likes Beginning Java and the fly likes Gradebook Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Gradebook" Watch "Gradebook" New topic
Author

Gradebook

nathan gibson
Ranch Hand

Joined: Sep 16, 2009
Posts: 120
im working on a program that makes something like a grade book. i have to use several algorithms. i have attached a copy of the instructions to save myself some typing. my basic questions are: is the way im doing this a way that will work? i have been following the instructions, along with examples from other sources to try to put this together. my efforts are sometimes lacking at best, but i dont really have a way of knowing what is wrong or what is right. so here is the code.


i know this isnt really alot of code, but i wanted to make sure i was getting off on the right foot before i got too deep and wasted alot of time. if anyone has feedback, tips, or advice i would love to hear them. thanks to anyone who can help.

*****************instructions******************
----------------------- Page 1-----------------------

16.05 Assignment Instructions



Instructions: For this assignment, you are going to use all your standard algorithm methods.



1. Create a folder called 16.05 Assignment in your module 16 assignments folder.

2. Create an abstract class called Student.

a. Student will need instance variables name , qz1, qz2, qz3, qz4, and

qz5 (of types String and int, respectively).

b. Student will need appropriate methods and constructors. To make things

interesting, create a getQuiz() method that takes in a quiz number as input and

then returns the appropriate quiz value. Likewise, setQuiz() will take as input

a quiz number and quiz score, and then put the value into the right variable. Make

sure to have a toString() method that prints the name of the student along

with the quiz scores.

c. Save the class as Student.java.

3. You are to create a class called TestStudent and save it as TestStudent.java.

a. Make sure that you create an array called myClass. Add the following students

with their quiz scores.



Candidate Q1 Q2 Q3 Q4 Q5

Mark Kennedy 70 80 90 100 90

Max Gerard 80 85 90 85 80

Jean Smith 50 79 89 99 100

Betty Farm 85 80 85 88 89

Dilbert Gamma 70 70 90 70 80



b. Create a method called printBook() that traverses through the array and prints

out each element.

c. Create a method called replaceName() that replaces a student’s name with a

new one.

d. Create a method called replaceQuiz() that replaces a student’s quiz grade

with a new one. It should replace only one quiz grade, as indicated, when it is

called. It will have the array, quiz number, and quiz value as input.

e. Create a method called replaceStudent() that replaces a student with

another one. It will have the array, name to replace, new student name, and quiz

scores as input.

f. Create a method called insertStudent() that inserts a new student before

another student in the array. It will have the array, name to find, new student

name, and quiz scores as input.

g. Create a method called deleteStudent() that finds a student by name and

then deletes that student.

h. Remember to make sure your methods handle there being null elements in the

array.

i. Test your methods. The output should be similar to that shown below:


----------------------- Page 2-----------------------


----------------------- Page 3-----------------------

4. Now create a class TestStudent2 and save it as TestStudent2.java.

a. Create the same items as for TestStudent; however, use an ArrayList instead.

b. Output will look similar to that shown below.


----------------------- Page 4-----------------------


----------------------- Page 5-----------------------


Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2853
    
  11

Programming can be frustrating when you start. Like everything else, it just takes some practice. You've found your way here though, so that's a good start!

I have a couple of hints for you. Your assignment says you will need instance variables q1, q2, q3, q4, and q5. You only have one integer instance variable called quiz. Your toString() method tries to compensate for this by using all those variables as parameters, but that's not what you want. You want a toString() method that takes no parameters and just works with instance variables. Finally, q1 + q2 + etc. isn't doing concatenation (putting two strings together); it's adding up all the integers into a total ... also not what you want.

Take another stab at it and post it here. Good luck!
nathan gibson
Ranch Hand

Joined: Sep 16, 2009
Posts: 120
i have tried to use all the suggestions listed. the main thing that is confusing me is how i am going to get my methods to work with receiving my data from my arrays. i have used cases to try to get my methods to be able to select the needed data to return... its really a shot in the dark, so if that wont work im open to any suggestions. also i have set up a multi- dimensional to hold my students and their grades, same shot in the dark. im trying my best, but there is alot about this that i dont really understand. im more confused about the way to go about how to solve this, than the actual java part of it. anyways, here is my current code:

nathan gibson
Ranch Hand

Joined: Sep 16, 2009
Posts: 120
i have been trying to think my way through the parts i dont understand. i changed my array, and i think it is for the better:


im still really struggling. some tips as of what direction to go in would be a life saver. i have been waiting diligently for replies. appreciation goes out to anyone who can help.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39387
    
  28
nathan gibson wrote:i have been trying to think my way through the parts i dont understand. . . .
At this point you will have to resort to desperate measures, using very high-tech equipment: paper, pencil and eraser. Preferably a big eraser; you will use it a lot

Write down exactly what you think your program should do, but leave large gaps between your stages. Then divide each stage and subdivide it until you have really tiny steps. Find a copy of Code Complete by Steve McConnell and have a look at the chapter about the pseudocode process. That is what you are doing here. You want to get the whole thing down to words of one syllable which anybody can understand. Then turn it into code. You might end up throwing away most of what you have done before, but you will have something which works.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39387
    
  28
Also get one method working before you try a second method.
nathan gibson
Ranch Hand

Joined: Sep 16, 2009
Posts: 120
thanks campbell for the good reply, also after my class im thinking about picking that book up. i thought my program through and made some very necessary changes. im hoping that you guys will have mercy on me. i have fixed my code up to here.




from here i have fixed my array and my instance variables. now precisely what im trying to accomplish is:
The setQuiz method needs to accept a quiz number and the score for that quiz.

getQuiz accepts a quiz number and returns the score for that applicable quiz.


the reason im having trouble with this is that i have 5 quizzes for 5 different students. im not sure how to write the method that it returns the way im trying to get it to. thanks if anyone can help me get this sorted out.

nathan gibson
Ranch Hand

Joined: Sep 16, 2009
Posts: 120
just an update, im changing the arraylist to an array, like so:


sorry, just noticed i have to do two versions, one with array && the other with list.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39387
    
  28
Get one version working (a List is probably easier to handle than an array) then start on the other version. The conversion will be easy.
nathan gibson
Ranch Hand

Joined: Sep 16, 2009
Posts: 120
im making progress with my methods in my tester class:


my only problem is the last line in my insert student method. "list[location] = new student(addN, addS);" where student is giving the error cannot find symbol consructor student. so far that is my only error in this class, but i cannot find the problem.

nathan gibson
Ranch Hand

Joined: Sep 16, 2009
Posts: 120
im working on finishing this project up. im getting the right output and everything, i really dont understand how though.



my last leg to complete is to finish the two methods i have been having trouble with all along. at this point im begging for some insight. i have been looking at examples, but i cant fins any that fit my specific situation. im going to keep looking. if anyone can help me out with this, thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Gradebook