Don't do people's assessed work for them! This chump doesn't deserve to pass his (or her) course.
Type: Posts; User: Shambolic
Don't do people's assessed work for them! This chump doesn't deserve to pass his (or her) course.
I would just remove the static modifier from all your methods. That should fix your error.
However, there is a lot more wrong with your code. Consider your rollDie method. None of its
local...
It's probably got a remote control. If it doesn't work, try changing the batteries. Otherwise, you
could just pick it up and move it around, making robot noises (like BZZZT, or VWEEE-OO) with your...
.toString() is an instance method for Objects. You say your getPerson() method is returning
a char; a char is a primitive data type, not an Object! Just compare the returned value directly
to the...
% is the "modulo" operator. For integers a and b, a % b is the remainder when a is divided by b. Some examples:
8 % 3 = 2
11 % 5 = 1
n % 2 = 1 for n odd
n % 2 = 0 for n even
And so on......
Nobody is going to do your assignment for you. If you try it yourself, and run into specific
problems with parts of your code, we can then help you work out what you're doing wrong.
If you think about it, you can easily turn any for loop into a while loop.
Consider the following:
for(initialise; condition; increment)
{
//stuff
}
How can you write that as a while...
Oh wait, now I see why what you're doing is wrong. For A, B, C to form a triangle, it has to be true that A+B>C, A+C>B and B+C>A. In other words, all three have to be true. The reason your program...
James, the correct way to put code tags around your code is...
[ code ]
This is my code
[ /code ]
...but without the spaces between the brackets and "code" or "/code".
There is nothing wrong with having multiple constructors in the same class. In fact, it's very common.
It's hard to tell what you're trying to do, but if mainMethod should always use the same...
You have written
else if(A+C>C)
when you intended
else if(A+C>B)
It's amazing how walking away from a problem and coming back later can make such a difference!
Just yesterday I spent ages trying to write a simple algorithm (in Mathematica, not Java), but couldn't...
Your question is not very clear. Are you having trouble working out how to calculate the percentage, how to display it, or both? Or do you mean something else?
If there are N trials, and heads...
Lots of reasons! In fact you're probably likely to come across ints more often than floats. You just need to make sure you choose the right type of variable for what you want to do! :)
Ah, good point jassi. A String can be compared to a StringBuffer using the String.contentEquals(StringBuffer) method; String.equals(Object) will always return false if the Object is not a String. ...
Is the output from the following two lines what you expect it to be?
System.out.println("palindrome: " + palindrome);
System.out.println("numbers: " + numbers);
I'm guessing it's not. ...
If it has a decimal point, then it's not an int!
You need
float whatever = Float.parseFloat(Sa);
Also note the usual java convention that variables are in all lower case. Conventions like...
Do you read through your code systematically? Pretend you are a dumb computer, reading every line literally and doing what it says. For example, in the code you have written, what is the purpose of...
I think the 'pass' variable is playing a useful role, but the boolean 'done' is not. Why not try:
while(pass<entry.length-1)
{
//algorithm
}
Your getDescription method has a String parameter called value, and this hides the instance variable value. You should probably set 'value' in the constructor, and remove the parameter from...
I believe calling System.exit terminates everything.
Just put spaces in explicitly:
if(args.length <= 0)
System.out.print("Hello World");
else if (args.length > 0)
{
System.out.print("Hello");
for (int i = 0; i < args.length;...
I think you just want currency to be a String i.e.
String currency =UserInput.readString();
You are trying to create a variable called 'currency' which can hold an object of type Sterling, but it seems you haven't written a class called Sterling, hence the compiler error.
This is only a minor thing, but you can simply your if statement. Instead of...
if ( (i % 2 == 0 && j % 2 == 0) || ( i % 2 == 1 && j % 2 == 1) )
...you can just write
if((i+j)%2 ==...