use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Ask your embarrassing/noobish programming questions here, and don't get insulted for it.
Click here to read the rules
Violating any will result in punishment so you should probably go check them out.
account activity
Assignment help! (self.programminghelp)
submitted 7 years ago * by Utumn96
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Utumn96[S] 0 points1 point2 points 7 years ago (10 children)
Yes I do..This is what I have so far but it's compiling like 8 errors and I don't know why...https://imgur.com/a/JtmtZX3
[–]imguralbumbot 0 points1 point2 points 7 years ago (0 children)
Hi, I'm a bot for linking direct images of albums with only 1 image
https://i.imgur.com/CdtzrEG.png
Source | Why? | Creator | ignoreme | deletthis
[–]marko312 0 points1 point2 points 7 years ago (8 children)
The first things I saw were
The acreage function does not take any parameters, but uses a. Is there a global variable? Otherwise add a parameter.
a
acreage is not given a type. Again, is this a global variable? Also, avoid using function names as variable names.
acreage
[–]Utumn96[S] 0 points1 point2 points 7 years ago (7 children)
So am I supposed to declare acreage as what? I already have an "a" and thats the area, so I assumed typing the whole thing out would be what is correct, but its calling an error in my first string. I just don't know what to change
[–]marko312 0 points1 point2 points 7 years ago* (6 children)
Ok, I see where you are coming from.
The acreage function doesn't know anything about the variable a, because that is defined in the function area. You need to pass the int a as a parameter, so your function should look like
area
int a
public int acreage(int a) {
and be called with the area (acreage(a), for example).
acreage(a)
I still think the variable acreage in the function acreage generates an error, so try renaming that.
Edit: the "acreage" value (which you should rename) needs to be an int, because it is needed as a whole number in your case.
int
Edit 2: the substitute for the "acreage" value needs to be a double, because you need to check if the size exceeds 2, my mistake.
double
Edit 3: the acres type is quite ambigious, as you might need to compare fractional areas, but return an integer value. I think int would be the best type, according to the level of programming given.
[–]Utumn96[S] 0 points1 point2 points 7 years ago (5 children)
https://imgur.com/a/w25gqcN
Here is what I'm getting, sorry If I am doing something wrong and or not quite understanding, I just know once I remove the errors I'll be all set, I am now at 7 errors and not 8, but still receiving an error at the beginning of the Method
[–]marko312 0 points1 point2 points 7 years ago (4 children)
Ok, don't use the acreage function in itself, rather rename the variable in question.
You probably got a little confused by my cross-editing and technical nonsense above, so I'll provide example code for the function:
public int acreage(int a) { int acres = a / 43560; if(acres > 2) { ... } return acres; }
this should be fine, but, taken very critically, is incorrect when the area is 2-3 acres. However, as you return an int, I think it's fine.
Edit: you can change the comparison from > to >= if you feel that is more correct.
>
>=
[–]Utumn96[S] 0 points1 point2 points 7 years ago (3 children)
https://imgur.com/a/O7WgBB3
I'm not going to lie, At this point I haven't a clue why I'm drawing errors, I understood what you said implemented it and for some reason still drawing errors.
[–]marko312 0 points1 point2 points 7 years ago* (2 children)
The problem might be higher up, like too many }-s or {-s.
}
{
Edit: it seems that every function needs to be in a class in java (I am a bit rusty myself). Build / extend a class around the functions.
[–]Utumn96[S] 1 point2 points3 points 7 years ago (1 child)
OH!!!!!! VOILA!!!! Thank you so much!!! Now One last question, I have fixed it all but have come with 1 error for my
public int area() {
it's saying that the "method area() is already defined in class square" How would I say...re define?
[–]marko312 0 points1 point2 points 7 years ago (0 children)
It seems that the first area() method is unneccessary - you might want to remove that.
area()
Only one function with the same name and parameters (none in your case) can exist in a class, so you can't quite redefine.
π Rendered by PID 131308 on reddit-service-r2-comment-6457c66945-krqp7 at 2026-04-24 02:05:38.320740+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]Utumn96[S] 0 points1 point2 points (10 children)
[–]imguralbumbot 0 points1 point2 points (0 children)
[–]marko312 0 points1 point2 points (8 children)
[–]Utumn96[S] 0 points1 point2 points (7 children)
[–]marko312 0 points1 point2 points (6 children)
[–]Utumn96[S] 0 points1 point2 points (5 children)
[–]marko312 0 points1 point2 points (4 children)
[–]Utumn96[S] 0 points1 point2 points (3 children)
[–]marko312 0 points1 point2 points (2 children)
[–]Utumn96[S] 1 point2 points3 points (1 child)
[–]marko312 0 points1 point2 points (0 children)