Maksym Trojanowski

Greenhorn
+ Follow
since Jan 29, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
5
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Maksym Trojanowski

Greg 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?

I will know that for next time, and yes i can XD
12 years ago

Greg 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?

Never mid you are a genius. I don't know why i didn't think of it first
12 years ago

Greg 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?

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 thing
12 years ago
Yes, like the subject says: How do i get the index of a character in an array? Help would be appreciated XD
given that this is the array. How would i find the index of 'm' for example?
12 years ago
I'm using JCreator LE and i'm having a problem getting the right file to execute. I just finished working on a program and started another one; the compiler checks for the next program but when i click the execute button, the previous file runs. Any way to fix this?

Philip 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

lol alittle late but thanks alot. Ill know it for next time
12 years ago

Runrioter 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?

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 face
12 years ago

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

12 years ago

Bear 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.

I'm sorry, i put it within the the slashes -_- The one you just edited out lol
12 years ago
I just accidentally deleted the code of my program, but when I compile it, it still runs. How can I get the code back?
12 years ago
12 years ago