• 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

Challenge Program.

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I almost have this project completed just getting a few errors and would like a check over to see if I have got all of this correctly.

Here are the Assignment Instructions.


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 a 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. In this assignment you may choose to use either an array or an ArrayList; there is
no need to do two versions of the program.
b. Make sure that you create data structure 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
c. Create a method called printBook() that traverses through the data structure
and prints out each element.
d. Create a method called replaceName() that replaces a student’s name with a
new one.
e. 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 data structure, quiz number, and quiz value as input.
f. Create a method called replaceStudent() that replaces a student with
another one. It will have the data structure, name to replace, new student name,
and quiz scores as input.
g. Create a method called insertStudent() that inserts a new student before
another student in the data structure. It will have the data structure, name to find,
new student name, and quiz scores as input.
h. Create a method called deleteStudent() that finds a student by name and
then deletes that student.
i. Remember to make sure your methods handle there being null elements in the
data structure. j. Test your met



Here is my code:



 
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your class names are wrong - Java is case sensitive.
2b - Your getQuiz and setQuiz methods don't do anything.
3b Your data structure should be called myClass.
 
Christopher Goad
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know that's the problem... what should go into the getQuiz and setQuiz method?
What data structure?
 
Stuart A. Burkett
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Christopher Goad wrote:I know that's the problem...


Then as I said in your other post, you are more likely to get help if you explain what your exact problem is rather than relying on the people here to work it out.

Christopher Goad wrote:what should go into the getQuiz and setQuiz method?


The getQuiz method should have an int parameter which indicates which quiz result is to be returned. The method should return the result asked for. e.g. if the parameter is 2, the method should return the value of qz2.
The setQuiz should have two parameters - the quiz number and quiz score and it should reste the value of the appropriate quiz variable. e.g. if the parameters are 2, 78, you need to set the value of qz2 to 78.


Christopher Goad wrote:What data structure?


The array or ArrayList mentioned in 3a
 
Christopher Goad
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there any way you could show me what you mean?
 
Stuart A. Burkett
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Christopher Goad wrote:Is there any way you could show me what you mean?


A parameter is a variable declared as part of the method signature
e.g. in your printBook method

list is a parameter

Your getQuiz method needs to have one int parameter.
Your setQuiz method needs to have two int parameters.

Try just that part first.
 
Who among you feels worthy enough to be my best friend? Test 1 is to read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic