Beginner in need of assistance/pointers in programming

I would love if someone had a few minutes to help me in my programming, I usually am alone doing this trying to learn and all, which entails a bunch of guess and checking with no real pin point of where I went wrong.

This is a script/program done on textpad, for getting an average for testgrades. You are prompted to enter a total number of grades, then enter each score. It will then calculate an average and match that average up with a letter grade to display. I have it compiling with no errors, but it will not display anything back. I was told I have to call a method after it calculates the average but I'm not quite sure what that is, I thought I did with the else/else if check method going on in there. I think I have something mislabeled in there or not supposed to be a double etc.

anyone that has a few minutes can you explain in the beginner terms how I went wrong or how I can fix it on my own. Thanks in advance. I really want to learn, just a lot of the guides I've looked up are talking about things in ways I guess I haven't learned throughly.

Yeah I still don't quite understand so I took your advice and came here, I didn't want to pester you with more clarification since I was on the understanding "public void checkgrade()" was starting/calling it. And I'm still trying to figure it out what you mean and where this is messed up.

And people in my experience get pretty mad when you keep asking for further explanation. and after working a lot on this on my own and trying to teach myself then feeling totally defeated I just didn't want to add insult to injury if you got upset.

I think you just need to be a little more clear in your question. Lets start at the beginning (kind of). A program works in layers. The first method (layer) that gets executed is the main method (public static void main (String[] args)). From there you call other methods which add to the layer. Whenever a method is called the program "breaks" and a note is made of where the code was stopped, and it continues with the method called.

So if I were to call a method called getScores and it would be called from the main method the program stack (where the computer keeps track of what methods were executed) would look like this

getScores
main

and then if get scores called a method lets say update(), then the stack would look like

update
getScores
main

when the method finishes executing, then the program return to where it left off in the previous method. So if update finishes then the stack will return to what it looked like in the first one.

What your program does it that it takes an input from the user for the test results or marks, and it then averages them. You then have another method called checkgrade() that checks which grade the average falls into and then updates the display to show that grade. Your problem was that you were not calling that method, and such the display didn't update. Generally you want your program to have a simple layout (a logical one). So just because you can put the update display in the main method, you may not want to because if they don't enter in test scores, then it would be a waste to update the display (though this really only matters when you are updating the display in a loop). I hope this clarifies. If you would like more information please specify a specific topic that you would like us to clarify.

PS. If you con't call a method then it won't execute. You can have methods in your code that aren't run.

EDIT: I read through your question again, and I may be able to clarify a little bit more. You stated that

I was on the understanding "public void checkgrade()" was starting/calling it

The general structure of a method is the following

visibility returnType name (paramater)

When creating a method it doesn't automatically call itself. It just allows you to call it. So essentially the public void checkgrade is a door into a room containing the code. You woun't be able to see or read the code unless you go to the door and open it. It is the same with the methods. The method allows you to store a group of commands in order to accomplish something. However if you don't call the method (go into the method), then you will not be able to execute that code. That is why we needed to put the checkgrade() in the calculateAverage method. It was to execute the method to update the display.

Okay like for instance another program (linked part below) that did work successfully for me was a similar one, except that it didn't do any calculations it was a get input then check style method. So the "method" in this one is that top line correct? And since it was just doing 1 thing in the entire application I didn't need a 2nd method called into the mix. But this current program I have to not only get the inputs and make the calculation it has to then match it up. So before that section would I need another "public static void (string[] args)" to start/call that 2nd method? Or am I still far off base?

Okay this gets weirder but I guess further verifies that my 'checking/mathing' isn't being called. Because if I make the values curriences for whatever reason instead of regular numbers I get a number displayed which is the correct average, just a money value not a letter grade.

I even tried to set this up a different way where it will show the number average and have a commentary box where it will show the matching letter grade http://pastebin.com/y68J1phP

I'll explain a little more about methods and now constructors. The main method (public static void main (String[] args)) is a special type of method. There is only one main method in any program (there can be more for debugging purposes, but lets just stick with one). This is the method that java searches for when it starts an application (if you don't include it it throws an error). so you want everything to start from the main method. A constructor is essentially a method that is automatically executed when an object is created (in this case when you create the CinemaPrice object). Here is a sample program

public class Sample{
// the constructor is challed when I create a new Sample()
public Sample (){
runProgram();
}
// the main method gets executed first
public static void main(){
Sample s = new Sample();//could just be new Sample, but it doesn't matter
runOnce();
}
// runOnce is called once from the main method.
public void runOnce(){
}
public void runProgram(){ // runProgram is called whenever a new Sample object is created
}
}

so in this case the stack would look like this

main

|
v

Sample
main

|
v

runProgram
Sample
main

|
v

Sample
main

|
v

main

|
v

runOnce
main

|
v

main

|
v

(program exits)

In your example the main method is the first method, but the main, checkJButtonActionPerformed and getVoterAge are all methods. The main method just gets executed first. A program can contain as many methods as you want. For example if you make a simple number guessing game you will probably want to make a method for:

generating a number
resetting all the data
the UI
getting the input
main method - must

Methods are used to break a complicated task into multiple simple ones. for example if you make a store program it would be difficult to make a whole store, but if you break it up so that one method handles inventory, one handles income, one handles ordering, one customer support, etc. the task becomes simpler. After the separate tasks are done, your job is to connect them in an efficient manner so that all the functions work.

So this isn't calling that section into action (code attached); I see the main method for the whole program the section that one I linked previously that's tied in near the exit on close.

I'm understanding a bit what you mean from your diagram, just trying to match this up to what I'm seeing visually on what I have to try and see how this would work. I see what I have that public void checkgrade now that isn't a method, just looks pretty similiar to the void runonce etc which is probably what's confusing me.

public void checkgrade is a method. it has the visibility (public) the return type (void), name (checkgrade) and the parameters (none). The partial code that you posted is the room with the door and the code inside it. you need to open the door (call the method (checkgrade()) would be calling it) to run the code inside. I probably should have specified that everything in my code is a method. a method can take a variety of different forms.

the look of a method depends on what it needs to accomplish. if you need it to return a value (like an average for example) then it needs a return type. If you want it to only be visible in the class(Java can work with multiple classes interacting. More advanced. Take my word for it) you are working with then the visibility needs to be private. If you need it to do set things like update a display you may or may not need parameters. If you haven't already read this. It may help clarify some things about methods. Again just because you create a method doesn't mean it runs. You need to open the door before you can get inside. The same way you need to call a method before you can execute the code inside.

Would this be anywhere closer to where I need to be? I thought I was recalling that average I just calculated previously, and was on the right track but then I still don't get any output from what I put into the prompts. :/

I fixed the issue where it wouldn't display the numerical value back to me. I have that working at least. I'm still not calling this method right for the letter value to display back in relation to that number.

Hi. so this is actually a continuation from another question of mine[Here](https://www.daniweb.com/programming/software-development/threads/506795/dynamically-add-values-into-datagridview-cell-from-listbox-vb2010) but i was advised to start a new thread as the original question …

I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...

Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...