r/programminghelp • u/BlazingBone • Sep 08 '18
Throws out error Compilation Failed. The brackets and text "kg" seem to trigger the error.
1
u/voncheeseburger Sep 08 '18
what are you trying to acheive? i've never seen any language that uses that syntax
3
u/BlazingBone Sep 08 '18
Java and I'm trying to achieve it to aknowledge that kg is a unit that comes after 0.5. Basically it's a finnish online Java course, hence the language.
1
u/voncheeseburger Sep 08 '18
I dont know of any programming language that allows you to use (unit) during a variable assignment
1
u/CommonMisspellingBot Sep 08 '18
Hey, voncheeseburger, just a quick heads-up:
acheive is actually spelled achieve. You can remember it by i before e.
Have a nice day!The parent commenter can reply with 'delete' to delete this comment.
1
u/jhilden13 Sep 08 '18
I don’t believe that the kg means anything in this context and is messing up the value. Is it necessary, or could it be in a comment after the statement?
2
u/BlazingBone Sep 08 '18
No. The brackets get in the way giving out the same error. And if I do it without brackets, then the excercise won't pass as it is a course with right and wrong answers. The code I change goes to a server at an university. There it gets checked if certain pieces of the code match a predetermined "right" answer. Apparently one of these pieces that have to be right is the (kg).
1
u/jhilden13 Sep 08 '18
Interesting, I couldn’t find any examples or information on this usage online, unfortunately.
1
3
u/PageFault Sep 09 '18 edited Sep 09 '18
Ok, everyone is being vague and cryptic as fuck and I don't know what their problem is.
It's obvious that it is Java since your filename is MuuttuvatMuttujat.java.
The issue is that you don't understand how to assign a double, and that's fine. A double type can only be assigned a float value, and isn't able to do anything with the unit type.
Your variable should be assigned as:
Though it would be better to make the unit type as part of the variable nimae
The only thing I'm going to give you shit about is taking a picure of your screen with your phone and posting that.