Thanks for letting me know. I just wasn't sure and didn't want to take the chance.
Type: Posts; User: StephenCoyle
Thanks for letting me know. I just wasn't sure and didn't want to take the chance.
I understand that, you mentioned above about the grades being entered as Strings.
the typing error of Void instead of void is the problem. Your code will compile when you change it (I have BlueJ and it compiles). I don't think I could have directly told you as I have a mark...
Surely you would use an integer to read in marks?
check over your code and make sure you have the basic outline for java typed out correctly. Remember that Java is case sensitive.
Start with writing down the logic/algorithm for the validation.
For example, you want the user to repeatedly enter a value until it is valid (between 0 and 100), so you would use a loop for this.
You don't seem to require a return statement for your code. You only have 1 method declared. I take it your using BlueJ. Just take a look at how you have declared your main method.
Norm is trying to help you to help yourself. You can't learn something if people just give you the answer. Especially in programming. Now look at this line off code I quoted and look at how the...
If your looking to store ints in a 2d array then print them, then dont use an array list. It seems to me by using an arraylist to store a 2d array you are over complicating the problem. The original...
PMT = (P - D)*r/12
______________
(1-(1+r/12)^-m)
Ok this is the formula. Do me a favour and post up what values you are using and the expected result.
Also...
Even try solving the problem, using a pen and paper. Make sure that its correct. For example :
housePrice = 30000.00
downPayment = 5000.00
then write it out like ( ((30000.00 - 50000.00) * ......
I should have mentioned that in my getFileSize method I do have a while loop and a counter. Its the counter that is returned.
I have it working this way. Thanks for the replies.
Thanks. I was thinking something like that.
What I have done now, is just created a getFileSize method that takes the file name as a parameter and returns an int (the size of the file).
I have written a simple program that reads in 30 first names from a txt file into an array and 20 surnames from another txt file into another array. All I want to know is, is it possible to create an...
Start here - Tasks to do 1. Design solution using Step form Algorithm / flow chart.
Using Stepwise Refinement - A way of developing a computer program by first describing general functions, then...
Norm I use BlueJ as well for my degree and the error it gives you is 'incompatible types', then highlight in red what code its referring to.
i.e double miles = feet * foot;
Your code compiles because it's syntax is correct. However as already mention
Java Tutorials - Defining Methods
ArrayIndexOutOfBoundsException - Thrown to indicate that an array has been accessed with an illegal index. The index is either negative or greater than or equal to the size of the array.
...
required: int[]
found: int
Norm has shown you the resolution. And the error code tells you what the problem is.
Read and understood. Sorry.
--- Update ---
I should have known better.
It might help to indent your code properly. You can read it better. But anyway this is what I have been able to do :
**** Please don't spoonfeed code
Why are you using an array called args[0]?
Wrap your code in the [CODE] blocks and format it so its easier to read and and understand.
1 way to do this would be :
String 1to10;
if (num >= 1 && num <= 10)
1to10 += "* ";
The problem has been solved by Zyrion. The problem is with the way you are trying to evaluate the if statements a==b or b==a. As Zyrion said use a==1 or b==2 to solve the problem.
Also, there is no need for the if-else-if statement. Just use if-else. for example :
if (hasTail)
System.out.println("A " + name + " has a tail");
else
System.out.println("A " + name + "...