I will know that for next time, and yes i can XDGreg Brannon wrote:Okay, easy enough.
So you'll have to write your own public static int indexOf( char y ) method. How that goes, roughly, is you compare each element of the char[] array at a time to the desired character, y, in a loop that iterates 0 - the length of the array, and when you find a match, you return the value of the loop's index variable.
(That was the kind of answer I was hoping to get to my first question.)
Can you code that?
Never mid you are a genius. I don't know why i didn't think of it firstGreg Brannon wrote:Context is always helpful. There are many ways (I'm not going to count them) to do this problem, but starting with a char[] array may not be at the top of my list. Do you have to use a char[] array? Did you consider just using a String = "abcdefg......z" with its available methods? Or, even better (some would say), a HashMap or other collection that returns a value for an input?
well this is my program so far The problem is at line 21, i just don't know the thingie to call the character in the array. This is basically a program that adds up the letter scores of a SCRABBLE word and don't worry about the EasyReader thingGreg Brannon wrote:Do you have any guesses? How do you do it in your head or with a piece of paper and a pencil? Can you describe that process and then program it?
lol alittle late but thanks alot. Ill know it for next timePhilip Thamaravelil wrote:if you still have the class files, just get a good java de-compiler to get your code back.. Won't be exact match of the original, but will work.
JAD works well.
Cheers,
Philip
The EasyReader is not the problem, EasyReader is a tool to make programming easier for noobs. Basically i was trying to return an array and print out the elements of the array but i wasn't able to and i would get this [I@9304b1 but when i tried using Arrays.toString it would say that it's not found and sad faceRunrioter Wung wrote:
I think that you should "import ..." to let the compiler find the class named "EasyReader".
Do you use an IDE to code? Notepad?
Maksym Trojanowski wrote:[code]import java.util.Scanner;
import java.util.Arrays;
[Edit: please watch your language]
public class Test
{
public static void main(String[] args)
{
EasyReader console = new EasyReader();
System.out.print("Enter first number to see if you have a pythagorean triple: ");
int m = console.readInt();
System.out.print("Enter second number to see if you have a pythagorean triple: ");
int n = console.readInt();
int[] array2 = (makePythagoreanTriple(m,n));
System.out.println(Arrays.toString(array2));
}
public static int[] makePythagoreanTriple(int m, int n)
{
if (m <= n)
{
int temp = n;
n = m;
m = temp;
}
int a = ((int)(Math.pow(m,2)) - ((int)(Math.pow(n,2))));
int b = (2 * m * n);
int c = ((int)(Math.pow(m,2)) + (int)(Math.pow(n,2)));
int[] array = {a, b, c};
return array;
}
This program does not work. May somebody help me in fixing it? I'm still a noob so help would be appreciated
I'm sorry, i put it within the the slashes -_- The one you just edited out lolBear Bibeault wrote:Welcome to the Ranch.
A few hints to help you out:
Firstly, please watch your use of language -- even in code comments. Thanks.
Secondly, please be sure to use code tags when posting code to the forums. Unformatted or unindented code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please click this link ⇒ UseCodeTags ⇐ for more information. Properly indented and formatted code greatly increases the probability that your question will get quicker, better answers. I have added code tags for you -- see the improvement?
And finally, it would greatly help if you'd actually tell us what the problem is. Just showing some code without any explanation isn't going to do you much good with regards to getting help on a problem that you haven't explained.