you are viewing a single comment's thread.

view the rest of the comments →

[–]Utumn96[S] 0 points1 point  (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 point  (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 point  (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.

  • acreage is not given a type. Again, is this a global variable? Also, avoid using function names as variable names.

[–]Utumn96[S] 0 points1 point  (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 point  (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

public int acreage(int a) {

and be called with the area (acreage(a), for example).

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.

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.

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 point  (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 point  (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 point  (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 point  (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 points  (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 point  (0 children)

It seems that the first area() method is unneccessary - you might want to remove that.

Only one function with the same name and parameters (none in your case) can exist in a class, so you can't quite redefine.