• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can somebody please help me with my program?  RSS feed

 
Maksym Trojanowski
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66306
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Maksym Trojanowski
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66306
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maksym Trojanowski wrote:I'm sorry, i put it within the the slashes -_-

Not really. What I removed was not helpful.

Please read TellTheDetails and ItDoesntWorkIsUseless (those are links) for help on figuring out what kind of information you can provide that will help you get the help you need.
 
Maksym Trojanowski
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66306
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you read the ItDoesntWorkIsUseless link?
 
Runrioter Wung
Ranch Hand
Posts: 30
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I think that you should "import ..." to let the compiler find the class named "EasyReader".
Also I found that "import java.util.Scanner" isn't used.
Do you use an IDE to code? Notepad?
 
Maksym Trojanowski
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Runrioter Wung
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maksym Trojanowski wrote:
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


The edited code works well.
Don't use "EasyReader" and I think there is something wrong with it.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:
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.


And finally finally, please UseAMeaningfulSubjectLine.(⇐click) Just saying "please help" tells us nothing about the nature of the problem. Many people won't bother reading the question if the subject line doesn't tell them it's a problem they might be interested in helping with.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!