Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Another "Fantastic" Static Method Problem I need help on...

 
Adam Favel
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have another program to write as well. It is a program that converts grades to letter grades, to GPA, and then prints it all out. it consists of four methods, and i only have the bare essentials of the program down at the moment, but i cannot figure out where to go from here.

here is my code if you are interested...


 
Adam Favel
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh yeah, i forgot to add that i haven't added in brackets in the if-else statements, and if i did, some of them are in the wrong places i think.

thanks
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what is your question? You say that you aren't sure where to go from here, but I'm not sure what your destination is myself. Can you describe what your program does so far and what it's supposed to do? This information will help us be able to point you along the right direction to finish this project.

Layne
 
Adam Favel
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
alright...here goes...

I am supposed to create a program that will collect and process student grade info. It has to be done with static methods, and 4 methods, including main. The main method asks for five marks in %. The markToGrade method should convert these to a Letter Grade and put into a string. Then the gradeToGradePoint is supposed to convert the Letter to GPA, and store that number for a later method. In the final method, its supposed to display all of this info, including the average, and display a message if over 3.0 or if below 2.0.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Let me see if I can help a bit.

1st, the above code, you need to follow Sun's variable naming standard. Each variable name starts with a lower case letter. So "String Grades;" should be "String grades;"

Unless your class assignment here, requires you naming your class a2q2, then give your class a meaningful name. Plus the standard is the class name begins with a capital letter.

"string name;"

This will not compile, since there is no such class as "string" the S is capitalized.




1. Grade is not a declared variable, you declared Grades, and then you try to pass grade to the gradeToGradePoint() method. These will not compile.
2. you are calling markToGrade with 5 parameters to a method that only accepts 1.

In your markToGrade method, line up the braces in your if/else statements. Also if you already checked for greater than 90, then the next if for greater than 90, does not need the less than 90, since those would already have been caught by the original if.

And finally, you might want to look into arrays, and looping for getting the actual grade point, because isn't that an average thing?

Mark
 
Horatio Westock
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.

People seem to be helping you sufficiently, so I won't add anything specific. However, I just wanted to ask a question. Could you quote the bit of your assignment specification that instructs you to use just static methods. I'm just trying to work out why you would be asked to do that specifically

I wonder whether it's to test something specifically, or to try and make things easier in some way? Who know?!
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does markToGrade(70) return? Why?
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I'm not quite ready to give any specific suggestions yet, myself. However, I have some questions for you to think about, and hopefully also respond to on this forum. First, what parts of this have you implemented? What parts do you still need to implement to finish the assignment? From there, you should pick a portion of what's left that seems resonable to work on. In a project like this, the teacher has described what methods you need to write, so I would write each method one at a time.

After taking a closer look at your code, it looks like you have already made a stab at implementing the markToGrade() and gradeToGradePoint() but still need to implement printTranscript(). So you may want to ask yourself what this function should do. From the name, I assume that it formats the output for the grade information. Does it print grades for a single student or for a whole class? Did your teacher give any specific requirements for the format of the output? If so work from that. If not you should determine how you want the output to appear.

Of course, I'm assuming that markToGrade() and gradeToGradePoint() are working. If not, what troubles have you encountered with these methods? If you need some help with these two methods, post as much detail as you can about the problems you are having. At the very least, you should include compiler and/or run-time errors.

Anyway, I hope this gets the cogs turning to help you think of what to do next. Let us know how things go.

Layne
 
Adam Favel
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again.

Thank you for all the help and suggestions you guys are giving me. You guys here are a lifesaver!

to answer a few questions that have risen:

- I am supposed to use Static Methods, Arguments/parameters, looping constructs, and "checking inputs" whatever that means.

- The Main method is supposed to ask for the Name, Student Number, and a set of marks in % form.
- The marktoGrade method is supposed to convert each mark from main to a letter grade according to a scale seen in my code.
- the gradetoGradePoint method is supposed to convert each mark from marktoGrade to a GPA according to a scale, also seen in my code.
- the printTranscript is supposed to display all the information asked for including name, student number, all letter grades in a string format, and an average GPA, done in this method.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by David Harkness:
What does markToGrade(70) return? Why?


Funny, but if he removes the less than checks, then that wouldn't be a problem.

Mark
 
Adam Favel
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think i just figured out my problem now...thank you for all of your help



Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic